// source --> https://www.saiseva.org/wp-content/plugins/everest-gallery/js/eg-frontend.js?ver=1.0.3 jQuery(document).ready(function ($) { function eg_reset_data_index(selector) { var count = 0; var total_items = selector.closest('.eg-wrap').find('a[data-lightbox-type]').length; selector.closest('.eg-wrap').find('a[data-lightbox-type]').each(function () { count++; $(this).attr('data-index', count); $(this).data('index', count); $(this).attr('data-total-items', total_items); $(this).data('total-items', total_items); }); } function eg_initialize_lightbox() { $('.eg-wrap').each(function () { var selector = $(this); var lightbox_status = selector.data('lightbox-status'); if (lightbox_status) { var lightbox_type = $(this).data('lightbox-type'); switch (lightbox_type) { case 'pretty_photo': var theme = selector.data('pretty_photo-theme'); var social_tools = selector.data('pretty_photo-social'); if (social_tools) { selector.find("a[data-lightbox-type='pretty_photo']").prettyPhoto({ theme: theme }); } else { selector.find("a[data-lightbox-type='pretty_photo']").prettyPhoto({ theme: theme, social_tools: false }); } break; case 'colorbox': var transition_type = selector.data('colorbox-transition'); selector.find("a[data-lightbox-type='colorbox']").colorbox({height: '90%', transition: transition_type}); break; case 'magnific_popup': selector.find("a[data-lightbox-type='magnific_popup']").magnificPopup({ type: 'image', gallery: {enabled: true} }); break; case 'photoswipe': if ($('.pswp').length == 0) { } break; } } }); } /* * Builds Pagination Links * * @param {int} current_page * @param {int} total_page * @param {int} gallery_id * @param {string} layout_type * @return {string} */ function build_pagination_html(current_page, total_page, gallery_id, layout_type) { var pagination_html = ''; if (current_page > 1) { pagination_html += '
  • <
  • '; } var upper_limit = current_page + 2; var lower_limit = current_page - 2; if (upper_limit > total_page) { upper_limit = total_page; } if (lower_limit < 1) { lower_limit = 1; } if (upper_limit - lower_limit < 5 && upper_limit - 4 >= 1) { lower_limit = upper_limit - 4; } if (upper_limit < 5 && total_page >= 5) { upper_limit = 5; } for (var page_count = lower_limit; page_count <= upper_limit; page_count++) { var page_class = (current_page == page_count) ? 'eg-current-page eg-page-link' : 'eg-page-link'; pagination_html += '
  • ' + page_count + '
  • '; } if (current_page < total_page) { pagination_html += '
  • >
  • '; } return pagination_html; } eg_initialize_lightbox(); $('body').on('click', '.eg-zoom', function () { $(this).closest('.eg-each-item').find('a[data-lightbox-type]').click(); }); $('body').on('click', '.eg-page-link', function () { var selector = $(this); selector.closest('.eg-pagination-block').find('.eg-page-link').removeClass('eg-current-page'); $(this).addClass('eg-current-page'); var layout_type = $(this).data('layout-type'); var page_num = $(this).data('page-number'); var gallery_id = $(this).data('gallery-id'); var total_page = $(this).data('total-page'); $.ajax({ type: 'post', url: eg_frontend_js_object.ajax_url, data: { action: 'eg_pagination_action', _wpnonce: eg_frontend_js_object.ajax_nonce, layout_type: layout_type, page_num: page_num, gallery_id: gallery_id }, beforeSend: function (xhr) { selector.closest('.eg-pagination-block').find('.eg-ajax-loader').show(); }, success: function (response) { if (selector.closest('.eg-wrap').find('.eg-filter-wrap').length > 0) { selector.closest('.eg-wrap').find('.eg-filter-trigger[data-filter-key="all"]').click(); } selector.closest('.eg-pagination-block').find('.eg-ajax-loader').hide(); if (layout_type == 'masonary') { var masonary_id = selector.closest('.eg-masonary-wrap').find('.eg-masonary-items-wrap').data('masonary-id'); masonary_obj[masonary_id].isotope('destroy'); selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').html(response); selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').imagesLoaded(function () { $('.eg-masonary-items-wrap').isotope({ itemSelector: '.eg-each-item', percentPosition: true, masonry: { // use element for option columnWidth: '.eg-each-item' } }); }); } else { selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').html(response); } eg_initialize_lightbox(); var pagination_html = build_pagination_html(page_num, total_page, gallery_id, layout_type); selector.closest('.eg-wrap').find('.eg-pagination-block ul').html(pagination_html); } }); }); /** * Load More Action * * @since 1.0.0 */ $('.eg-load-more-trigger').click(function () { var selector = $(this); var masonary_id = selector.closest('.eg-masonary-wrap').find('.eg-masonary-items-wrap').data('masonary-id'); var layout_type = $(this).data('layout-type'); var page_num = $(this).data('page-number'); var gallery_id = $(this).data('gallery-id'); var total_page = $(this).data('total-page'); var next_page = parseInt(page_num) + 1; if (next_page <= total_page) { $.ajax({ type: 'post', url: eg_frontend_js_object.ajax_url, data: { action: 'eg_pagination_action', _wpnonce: eg_frontend_js_object.ajax_nonce, layout_type: layout_type, page_num: next_page, gallery_id: gallery_id }, beforeSend: function (xhr) { selector.hide(); selector.closest('.eg-load-more-block').find('.eg-ajax-loader').show(); }, success: function (response) { selector.data('page-number', next_page); selector.closest('.eg-load-more-block').find('.eg-ajax-loader').hide(); if (selector.closest('.eg-wrap').find('.eg-filter-wrap').length > 0) { selector.closest('.eg-wrap').find('.eg-filter-trigger[data-filter-key="all"]').click(); } if (layout_type == 'masonary') { var $items = $(response); masonary_obj[masonary_id].append($items).isotope('appended', $items); masonary_obj[masonary_id].imagesLoaded(function () { }) .done(function (instance) { console.log('all images successfully loaded'); selector.closest('.ap_pagination').find('.ap_wait_loader').hide(); selector.show(); masonary_obj[masonary_id].isotope('reloadItems').isotope(); }) .fail(function () { console.log('all images loaded, at least one is broken'); masonary_obj[masonary_id].isotope('reloadItems').isotope(); }) .progress(function (instance, image) { }); } else { selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').append(response); } eg_reset_data_index(selector); eg_initialize_lightbox(); if (next_page == total_page) { selector.remove(); } else { selector.show(); } } }); } else { selector.remove(); } }); var masonary_obj = []; $('.eg-masonary-items-wrap').each(function () { var $selector = $(this); var masonary_id = $(this).data('masonary-id'); masonary_obj[masonary_id] = $selector.imagesLoaded(function () { masonary_obj[masonary_id].isotope({ itemSelector: '.eg-each-item', percentPosition: true, masonry: { // use element for option columnWidth: '.eg-each-item' } }); }); }); $('.eg-filter-trigger').click(function () { var selector = $(this); var filter_key = selector.data('filter-key'); var layout_type = selector.data('layout-type'); selector.closest('.eg-filter-wrap').find('.eg-filter-trigger').removeClass('eg-active-filter'); selector.addClass('eg-active-filter'); if (layout_type == 'grid') { if (filter_key == 'all') { selector.closest('.eg-wrap').find('.eg-each-item').removeClass('eg-hidden-grid').addClass('eg-visible-grid').show(); } else { selector.closest('.eg-wrap').find('.eg-each-item').addClass('eg-hidden-grid').removeClass('eg-visible-grid').hide(); selector.closest('.eg-wrap').find('.' + filter_key).removeClass('eg-hidden-grid').addClass('eg-visible-grid').show(); } } else if (layout_type == 'masonary') { filterValue = (filter_key == 'all') ? '*' : '.' + filter_key; var masonary_id = selector.closest('.eg-masonary-wrap').find('.eg-masonary-items-wrap').data('masonary-id'); masonary_obj[masonary_id].isotope({filter: filterValue}); } }); /** * Slideshow Layout initialization * * @since 1.0.0 */ var slideshow_obj = []; $('.eg-slideshow-items-wrap').each(function () { var selector = $(this); var pause_duration = selector.data('pause-duration'); var transition_duration = selector.data('transition-duration'); var mode = selector.data('mode'); var next_previous_controls = selector.data('next-previous-controls'); var play_pause_controls = selector.data('play-pause-controls'); var auto_start = selector.data('auto-start'); var adaptive_height = selector.data('adaptive-height'); var pager = selector.data('pager'); var pager_type = selector.data('pager-type'); var slideshow_id = selector.data('slideshow-id'); slideshow_obj[slideshow_id] = selector.bxSlider({ mode: mode, controls: next_previous_controls, auto: auto_start, pause: pause_duration, pager: pager, pagerType: pager_type, autoControls: play_pause_controls, speed: transition_duration, autoHover: true, adaptiveHeight: adaptive_height, autoControlsCombine: true }); // console.log(slideshow_obj); }); /** * Flimstrip Layout initialization * * @since 1.0.0 */ var filmstrip_obj = []; $('.eg-filmstrip-items-wrap').each(function () { var selector = $(this); var pause_duration = selector.data('pause-duration'); var transition_duration = selector.data('transition-duration'); var mode = selector.data('mode'); var next_previous_controls = selector.data('next-previous-controls'); var play_pause_controls = selector.data('play-pause-controls'); var auto_start = selector.data('auto-start'); var adaptive_height = selector.data('adaptive-height'); var pager = selector.data('pager'); var pager_type = selector.data('pager-type'); var filmstrip_id = selector.data('filmstrip-id'); filmstrip_obj[filmstrip_id] = selector.bxSlider({ mode: mode, controls: next_previous_controls, auto: auto_start, pause: pause_duration, pager: true, autoControls: play_pause_controls, speed: transition_duration, autoHover: true, pagerCustom: '#eg-pager-' + filmstrip_id, adaptiveHeight: adaptive_height, onSlideBefore: function ($slideElement, oldIndex, newIndex) { selector.closest('.eg-filmstrip-outer-wrap').find('.eg-filmstrip-pager a').each(function () { if ($(this).data('slide-index') == newIndex) { $(this).addClass('eg-active-filmstrip'); } else { $(this).removeClass('eg-active-filmstrip'); } }); } }); // console.log(filmstrip_obj); }); /** * Filmstrip Pager Slider initialization * * @since 1.0.0 */ $('.eg-filmstrip-pager').each(function () { var min_slides = $(this).data('min-slides'); var max_slides = $(this).data('max-slides'); var slide_width = $(this).data('slide-width'); var move_slides = $(this).data('move-slides'); $(this).bxSlider({ minSlides: min_slides, maxSlides: max_slides, slideWidth: slide_width, slideMargin: 5, moveSlides: move_slides, pager: false, }); }); /** * Carousel initialization * * @since 1.0.0 */ $('.eg-carousel-items-wrap').each(function () { var selector = $(this); var pause_duration = selector.data('pause-duration'); var controls = selector.data('controls'); var auto_start = selector.data('auto-start'); var min_slides = $(this).data('min-slides'); var max_slides = $(this).data('max-slides'); var slide_width = $(this).data('slide-width'); var move_slides = $(this).data('move-slides'); $(this).bxSlider({ controls: controls, auto: auto_start, pause: pause_duration, minSlides: min_slides, maxSlides: max_slides, slideWidth: slide_width, slideMargin: 5, moveSlides: move_slides, pager: true, autoHover: true }); }); /** * Next Page Pagination * * @since 1.0.0 */ $('body').on('click', '.eg-next-page,.eg-previous-page', function () { var selector = $(this); var layout_type = $(this).data('layout-type'); var gallery_id = $(this).data('gallery-id'); var total_page = $(this).data('total-page'); var current_page = $(this).closest('.eg-pagination-block').find('.eg-current-page').data('page-number'); var next_page = parseInt(current_page) + 1; var previous_page = parseInt(current_page) - 1; if (selector.hasClass('eg-previous-page')) { current_page = previous_page; } else { current_page = next_page; } $.ajax({ type: 'post', url: eg_frontend_js_object.ajax_url, data: { action: 'eg_pagination_action', _wpnonce: eg_frontend_js_object.ajax_nonce, layout_type: layout_type, page_num: current_page, gallery_id: gallery_id }, beforeSend: function (xhr) { selector.closest('.eg-pagination-block').find('.eg-ajax-loader').show(); }, success: function (response) { selector.closest('.eg-pagination-block').find('.eg-ajax-loader').hide(); if (selector.closest('.eg-wrap').find('.eg-filter-wrap').length > 0) { selector.closest('.eg-wrap').find('.eg-filter-trigger[data-filter-key="all"]').click(); } if (layout_type == 'masonary') { var masonary_id = selector.closest('.eg-masonary-wrap').find('.eg-masonary-items-wrap').data('masonary-id'); masonary_obj[masonary_id].isotope('destroy'); selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').html(response); selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').imagesLoaded(function () { $('.eg-masonary-items-wrap').isotope({ itemSelector: '.eg-each-item', percentPosition: true, masonry: { // use element for option columnWidth: '.eg-each-item' } }); }); } else { selector.closest('.eg-wrap').find('.eg-' + layout_type + '-items-wrap').html(response); } eg_initialize_lightbox(); var pagination_html = build_pagination_html(current_page, total_page, gallery_id, layout_type); selector.closest('.eg-wrap').find('.eg-pagination-block ul').html(pagination_html); } }); }); /** * Everest Lightbox Initialization * * @since 1.0.0 */ $('body').on('click', 'a[data-lightbox-type="everest_lightbox"]', function (e) { var lightbox_status = $(this).closest('.eg-wrap').data('lightbox-status'); if (lightbox_status) { e.preventDefault(); var item_type = $(this).data('item-type'); var image_title = $(this).find('img').attr('alt'); var image_caption = $(this).attr('title'); var item_index = $(this).data('index'); var total_items = $(this).data('total-items'); var gallery_id = $(this).closest('.eg-wrap').data('gallery-id'); var lightbox_theme = $(this).closest('.eg-wrap').data('lightbox-theme'); var lightbox_themes = ['black', 'white', 'blue', 'grey']; for (var i = 0; i < lightbox_themes.length; i++) { $('.eg-everest-lightbox-overlay').removeClass('eg-' + lightbox_themes[i] + '-lightbox'); } $('.eg-everest-lightbox-overlay').addClass('eg-' + lightbox_theme + '-lightbox'); $('.eg-everest-lightbox-previous,.eg-everest-lightbox-next').data('current-index', item_index); $('.eg-everest-lightbox-previous,.eg-everest-lightbox-next').data('gallery-id', gallery_id); $('.eg-everest-lightbox-previous,.eg-everest-lightbox-next').data('total-items', total_items); $('.eg-everest-lightbox-caption').html(image_title); $('.eg-everest-lightbox-description').html(image_caption); switch (item_type) { case 'image': case 'instagram': case 'post': var image_url = $(this).attr('href'); $('.eg-everest-lightbox-source-holder').html(''); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); var $image_holder = $('.eg-everest-lightbox-source-holder'); $image_holder.imagesLoaded(function () { var image_height = $('.eg-everest-lightbox-source-holder img').height(); var image_width = $('.eg-everest-lightbox-source-holder img').width(); var window_height = $(window).height(); var window_width = $(window).width(); var max_height = window_height * 0.8; if (image_height > max_height) { var ratio = image_width / image_height; var image_width = max_height * ratio; $('.eg-everest-lightbox-overlay .eg-everest-lightbox-wrap').animate({ width: image_width }, 500); $('.eg-everest-lightbox-source-holder img').animate({ width: image_width, opacity: 1 }, 500); } else { var lightbox_width = $('.eg-everest-lightbox-overlay .eg-everest-lightbox-wrap').css('width'); var half_width = 0.5 * window_width; if (parseInt(lightbox_width) != parseInt(half_width)) { $('.eg-everest-lightbox-overlay .eg-everest-lightbox-wrap').animate({ width: '50%' }, 500); } } }); break; case 'video': var video_type = $(this).data('video-type'); var video_url = $(this).data('video-url'); var self_video_url = $(this).data('self-video-url'); switch (video_type) { case 'youtube': if (video_url == '') { alert(eg_frontend_js_object.strings.video_missing); } else { video_url_array = video_url.split('?v='); video_id = video_url_array.pop(); video_html = ''; $('.eg-everest-lightbox-source-holder').html(video_html); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); } break; case 'vimeo': if (video_url == '') { alert(eg_frontend_js_object.strings.video_missing); } else { video_url_array = video_url.split('/'); video_id = video_url_array.pop(); video_html = ''; $('.eg-everest-lightbox-source-holder').html(video_html); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); } break; case 'self-hosted': if (self_video_url == '') { alert(eg_frontend_js_object.strings.video_missing); } else { video_html = ''; $('.eg-everest-lightbox-source-holder').html(video_html); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); } break; } break; case 'audio': var audio_type = $(this).data('audio-type'); var audio_url = $(this).data('audio-url'); var self_audio_url = $(this).data('self-audio-url'); switch (audio_type) { case 'soundcloud': if (audio_url == '') { alert(eg_frontend_js_object.strings.audio_missing); } else { audio_html = ' '; $('.eg-everest-lightbox-source-holder').html(audio_html); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); } break; case 'self-hosted': if (self_audio_url == '') { alert(eg_frontend_js_object.strings.audio_missing); } else { audio_html = ''; $('.eg-everest-lightbox-source-holder').html(audio_html); $('.eg-everest-lightbox-overlay').addClass('eg-overlay-active'); } break; } break; } } }); /** * Everst Lightbox initialization * * @since 1.0.0 */ $('.eg-everest-lightbox-overlay .eg-close-pop-up').click(function () { $('.eg-everest-lightbox-overlay').removeClass('eg-overlay-active'); setTimeout(function () { $('.eg-everest-lightbox-source-holder').html(''); }, 500) // $('.eg-everest-lightbox-overlay').hide(); }); /** * Everest Lightbox Previous Trigger * * @since 1.0.0 */ $('.eg-everest-lightbox-previous').click(function () { var current_index = $(this).data('current-index'); var total_items = $(this).data('total-items'); var previous_index = parseInt(current_index) - 1; var click_index = (previous_index < 1) ? total_items : previous_index; var gallery_id = $(this).data('gallery-id'); $('.eg-wrap[data-gallery-id="' + gallery_id + '"] a[data-index="' + click_index + '"]').click(); }); /** * Everest Lightbox Next Trigger * * @since 1.0.0 */ $('.eg-everest-lightbox-next').click(function () { var current_index = $(this).data('current-index'); var total_items = $(this).data('total-items'); var next_index = parseInt(current_index) + 1; var click_index = (next_index > total_items) ? 1 : next_index; var gallery_id = $(this).data('gallery-id'); $('.eg-wrap[data-gallery-id="' + gallery_id + '"] a[data-index="' + click_index + '"]').click(); }); $('.eg-everest-lightbox-inner-overlay').click(function () { $('.eg-everest-lightbox-overlay .eg-close-pop-up').click(); }); }); // source --> https://www.saiseva.org/wp-content/plugins/photoblocks-grid-gallery/public/js/anime.min.js?ver=1.2.2 /* 2017 Julian Garnier Released under the MIT license */ var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(e,r,p){if(p.get||p.set)throw new TypeError("ES3 does not support getters and setters.");e!=Array.prototype&&e!=Object.prototype&&(e[r]=p.value)};$jscomp.getGlobal=function(e){return"undefined"!=typeof window&&window===e?e:"undefined"!=typeof global&&null!=global?global:e};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; $jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(e){return $jscomp.SYMBOL_PREFIX+(e||"")+$jscomp.symbolCounter_++}; $jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var e=$jscomp.global.Symbol.iterator;e||(e=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[e]&&$jscomp.defineProperty(Array.prototype,e,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(e){var r=0;return $jscomp.iteratorPrototype(function(){return rb&&(b+=1);1b?c:b<2/3?a+(c-a)*(2/3-b)*6:a}var d=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(a)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(a);a=parseInt(d[1])/360;var b=parseInt(d[2])/100,f=parseInt(d[3])/100,d=d[4]||1;if(0==b)f=b=a=f;else{var n=.5>f?f*(1+b):f+b-f*b,k=2*f-n,f=c(k,n,a+1/3),b=c(k,n,a);a=c(k,n,a-1/3)}return"rgba("+ 255*f+","+255*b+","+255*a+","+d+")"}function y(a){if(a=/([\+\-]?[0-9#\.]+)(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(a))return a[2]}function V(a){if(-1=g.currentTime)for(var G=0;G=w||!k)g.began||(g.began=!0,f("begin")),f("run");if(q>n&&q=k&&r!==k||!k)b(k),x||e();f("update");a>=k&&(g.remaining?(t=h,"alternate"===g.direction&&(g.reversed=!g.reversed)):(g.pause(),g.completed||(g.completed=!0,f("complete"),"Promise"in window&&(p(),m=c()))),l=0)}a=void 0===a?{}:a;var h,t,l=0,p=null,m=c(),g=fa(a);g.reset=function(){var a=g.direction,c=g.loop;g.currentTime= 0;g.progress=0;g.paused=!0;g.began=!1;g.completed=!1;g.reversed="reverse"===a;g.remaining="alternate"===a&&1===c?2:c;b(0);for(a=g.children.length;a--;)g.children[a].reset()};g.tick=function(a){h=a;t||(t=h);k((l+h-t)*q.speed)};g.seek=function(a){k(d(a))};g.pause=function(){var a=v.indexOf(g);-1=c&&0<=b&&1>=b){var e=new Float32Array(11);if(c!==d||b!==f)for(var k=0;11>k;++k)e[k]=a(.1*k,c,b);return function(k){if(c===d&&b===f)return k;if(0===k)return 0;if(1===k)return 1;for(var h=0,l=1;10!==l&&e[l]<=k;++l)h+=.1;--l;var l=h+(k-e[l])/(e[l+1]-e[l])*.1,n=3*(1-3*b+3*c)*l*l+2*(3*b-6*c)*l+3*c;if(.001<=n){for(h=0;4>h;++h){n=3*(1-3*b+3*c)*l*l+2*(3*b-6*c)*l+3*c;if(0===n)break;var m=a(l,c,b)-k,l=l-m/n}k=l}else if(0=== n)k=l;else{var l=h,h=h+.1,g=0;do m=l+(h-l)/2,n=a(m,c,b)-k,0++g);k=m}return a(k,d,f)}}}}(),Q=function(){function a(a,b){return 0===a||1===a?a:-Math.pow(2,10*(a-1))*Math.sin(2*(a-1-b/(2*Math.PI)*Math.asin(1))*Math.PI/b)}var c="Quad Cubic Quart Quint Sine Expo Circ Back Elastic".split(" "),d={In:[[.55,.085,.68,.53],[.55,.055,.675,.19],[.895,.03,.685,.22],[.755,.05,.855,.06],[.47,0,.745,.715],[.95,.05,.795,.035],[.6,.04,.98,.335],[.6,-.28,.735,.045],a],Out:[[.25, .46,.45,.94],[.215,.61,.355,1],[.165,.84,.44,1],[.23,1,.32,1],[.39,.575,.565,1],[.19,1,.22,1],[.075,.82,.165,1],[.175,.885,.32,1.275],function(b,c){return 1-a(1-b,c)}],InOut:[[.455,.03,.515,.955],[.645,.045,.355,1],[.77,0,.175,1],[.86,0,.07,1],[.445,.05,.55,.95],[1,0,0,1],[.785,.135,.15,.86],[.68,-.55,.265,1.55],function(b,c){return.5>b?a(2*b,c)/2:1-a(-2*b+2,c)/2}]},b={linear:A(.25,.25,.75,.75)},f={},e;for(e in d)f.type=e,d[f.type].forEach(function(a){return function(d,f){b["ease"+a.type+c[f]]=h.fnc(d)? d:A.apply($jscomp$this,d)}}(f)),f={type:f.type};return b}(),ha={css:function(a,c,d){return a.style[c]=d},attribute:function(a,c,d){return a.setAttribute(c,d)},object:function(a,c,d){return a[c]=d},transform:function(a,c,d,b,f){b[f]||(b[f]=[]);b[f].push(c+"("+d+")")}},v=[],B=0,ia=function(){function a(){B=requestAnimationFrame(c)}function c(c){var b=v.length;if(b){for(var d=0;db&&(c.duration=d.duration);c.children.push(d)});c.seek(0);c.reset();c.autoplay&&c.restart();return c};return c};q.random=function(a,c){return Math.floor(Math.random()*(c-a+1))+a};return q}); // source --> https://www.saiseva.org/wp-content/plugins/photoblocks-grid-gallery/public/js/packery.pkgd.js?ver=5.6.2 /*! * Packery PACKAGED v2.1.1 * Gapless, draggable grid layouts * * Licensed GPLv3 for open source use * or Packery Commercial License for commercial use * * http://packery.metafizzy.co * Copyright 2016 Metafizzy */ /** * Bridget makes jQuery widgets * v2.0.0 * MIT license */ /* jshint browser: true, strict: true, undef: true, unused: true */ ( function( window, factory ) { 'use strict'; /* globals define: false, module: false, require: false */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) { factory( window, jQuery ); }); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( window, require('jquery') ); } else { // browser global window.jQueryBridget = factory( window, window.jQuery ); } }( window, function factory( window, jQuery ) { 'use strict'; // ----- utils ----- // var arraySlice = Array.prototype.slice; // helper function for logging errors // $.error breaks jQuery chaining var console = window.console; var logError = typeof console == 'undefined' ? function() {} : function( message ) { console.error( message ); }; // ----- jQueryBridget ----- // function jQueryBridget( namespace, PluginClass, $ ) { $ = $ || jQuery || window.jQuery; if ( !$ ) { return; } // add option method -> $().plugin('option', {...}) if ( !PluginClass.prototype.option ) { // option setter PluginClass.prototype.option = function( opts ) { // bail out if not an object if ( !$.isPlainObject( opts ) ){ return; } this.options = $.extend( true, this.options, opts ); }; } // make jQuery plugin $.fn[ namespace ] = function( arg0 /*, arg1 */ ) { if ( typeof arg0 == 'string' ) { // method call $().plugin( 'methodName', { options } ) // shift arguments by 1 var args = arraySlice.call( arguments, 1 ); return methodCall( this, arg0, args ); } // just $().plugin({ options }) plainCall( this, arg0 ); return this; }; // $().plugin('methodName') function methodCall( $elems, methodName, args ) { var returnValue; var pluginMethodStr = '$().' + namespace + '("' + methodName + '")'; $elems.each( function( i, elem ) { // get instance var instance = $.data( elem, namespace ); if ( !instance ) { logError( namespace + ' not initialized. Cannot call methods, i.e. ' + pluginMethodStr ); return; } var method = instance[ methodName ]; if ( !method || methodName.charAt(0) == '_' ) { logError( pluginMethodStr + ' is not a valid method' ); return; } // apply method, get return value var value = method.apply( instance, args ); // set return value if value is returned, use only first value returnValue = returnValue === undefined ? value : returnValue; }); return returnValue !== undefined ? returnValue : $elems; } function plainCall( $elems, options ) { $elems.each( function( i, elem ) { var instance = $.data( elem, namespace ); if ( instance ) { // set options & init instance.option( options ); instance._init(); } else { // initialize new instance instance = new PluginClass( elem, options ); $.data( elem, namespace, instance ); } }); } updateJQuery( $ ); } // ----- updateJQuery ----- // // set $.bridget for v1 backwards compatibility function updateJQuery( $ ) { if ( !$ || ( $ && $.bridget ) ) { return; } $.bridget = jQueryBridget; } updateJQuery( jQuery || window.jQuery ); // ----- ----- // return jQueryBridget; })); /*! * getSize v2.0.2 * measure size of elements * MIT license */ /*jshint browser: true, strict: true, undef: true, unused: true */ /*global define: false, module: false, console: false */ ( function( window, factory ) { 'use strict'; if ( typeof define == 'function' && define.amd ) { // AMD define( 'get-size/get-size',[],function() { return factory(); }); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory(); } else { // browser global window.getSize = factory(); } })( window, function factory() { 'use strict'; // -------------------------- helpers -------------------------- // // get a number from a string, not a percentage function getStyleSize( value ) { var num = parseFloat( value ); // not a percent like '100%', and a number var isValid = value.indexOf('%') == -1 && !isNaN( num ); return isValid && num; } function noop() {} var logError = typeof console == 'undefined' ? noop : function( message ) { console.error( message ); }; // -------------------------- measurements -------------------------- // var measurements = [ 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth', 'borderBottomWidth' ]; var measurementsLength = measurements.length; function getZeroSize() { var size = { width: 0, height: 0, innerWidth: 0, innerHeight: 0, outerWidth: 0, outerHeight: 0 }; for ( var i=0; i < measurementsLength; i++ ) { var measurement = measurements[i]; size[ measurement ] = 0; } return size; } // -------------------------- getStyle -------------------------- // /** * getStyle, get style of element, check for Firefox bug * https://bugzilla.mozilla.org/show_bug.cgi?id=548397 */ function getStyle( elem ) { var style = getComputedStyle( elem ); if ( !style ) { logError( 'Style returned ' + style + '. Are you running this code in a hidden iframe on Firefox? ' + 'See http://bit.ly/getsizebug1' ); } return style; } // -------------------------- setup -------------------------- // var isSetup = false; var isBoxSizeOuter; /** * setup * check isBoxSizerOuter * do on first getSize() rather than on page load for Firefox bug */ function setup() { // setup once if ( isSetup ) { return; } isSetup = true; // -------------------------- box sizing -------------------------- // /** * WebKit measures the outer-width on style.width on border-box elems * IE & Firefox<29 measures the inner-width */ var div = document.createElement('div'); div.style.width = '200px'; div.style.padding = '1px 2px 3px 4px'; div.style.borderStyle = 'solid'; div.style.borderWidth = '1px 2px 3px 4px'; div.style.boxSizing = 'border-box'; var body = document.body || document.documentElement; body.appendChild( div ); var style = getStyle( div ); getSize.isBoxSizeOuter = isBoxSizeOuter = getStyleSize( style.width ) == 200; body.removeChild( div ); } // -------------------------- getSize -------------------------- // function getSize( elem ) { setup(); // use querySeletor if elem is string if ( typeof elem == 'string' ) { elem = document.querySelector( elem ); } // do not proceed on non-objects if ( !elem || typeof elem != 'object' || !elem.nodeType ) { return; } var style = getStyle( elem ); // if hidden, everything is 0 if ( style.display == 'none' ) { return getZeroSize(); } var size = {}; size.width = elem.offsetWidth; size.height = elem.offsetHeight; var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box'; // get all measurements for ( var i=0; i < measurementsLength; i++ ) { var measurement = measurements[i]; var value = style[ measurement ]; var num = parseFloat( value ); // any 'auto', 'medium' value will be 0 size[ measurement ] = !isNaN( num ) ? num : 0; } var paddingWidth = size.paddingLeft + size.paddingRight; var paddingHeight = size.paddingTop + size.paddingBottom; var marginWidth = size.marginLeft + size.marginRight; var marginHeight = size.marginTop + size.marginBottom; var borderWidth = size.borderLeftWidth + size.borderRightWidth; var borderHeight = size.borderTopWidth + size.borderBottomWidth; var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter; // overwrite width and height if we can get it from style var styleWidth = getStyleSize( style.width ); if ( styleWidth !== false ) { size.width = styleWidth + // add padding and border unless it's already including it ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth ); } var styleHeight = getStyleSize( style.height ); if ( styleHeight !== false ) { size.height = styleHeight + // add padding and border unless it's already including it ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight ); } size.innerWidth = size.width - ( paddingWidth + borderWidth ); size.innerHeight = size.height - ( paddingHeight + borderHeight ); size.outerWidth = size.width + marginWidth; size.outerHeight = size.height + marginHeight; return size; } return getSize; }); /** * EvEmitter v1.0.2 * Lil' event emitter * MIT License */ /* jshint unused: true, undef: true, strict: true */ ( function( global, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module */ if ( typeof define == 'function' && define.amd ) { // AMD - RequireJS define( 'ev-emitter/ev-emitter',factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS - Browserify, Webpack module.exports = factory(); } else { // Browser globals global.EvEmitter = factory(); } }( this, function() { function EvEmitter() {} var proto = EvEmitter.prototype; proto.on = function( eventName, listener ) { if ( !eventName || !listener ) { return; } // set events hash var events = this._events = this._events || {}; // set listeners array var listeners = events[ eventName ] = events[ eventName ] || []; // only add once if ( listeners.indexOf( listener ) == -1 ) { listeners.push( listener ); } return this; }; proto.once = function( eventName, listener ) { if ( !eventName || !listener ) { return; } // add event this.on( eventName, listener ); // set once flag // set onceEvents hash var onceEvents = this._onceEvents = this._onceEvents || {}; // set onceListeners object var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {}; // set flag onceListeners[ listener ] = true; return this; }; proto.off = function( eventName, listener ) { var listeners = this._events && this._events[ eventName ]; if ( !listeners || !listeners.length ) { return; } var index = listeners.indexOf( listener ); if ( index != -1 ) { listeners.splice( index, 1 ); } return this; }; proto.emitEvent = function( eventName, args ) { var listeners = this._events && this._events[ eventName ]; if ( !listeners || !listeners.length ) { return; } var i = 0; var listener = listeners[i]; args = args || []; // once stuff var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; while ( listener ) { var isOnce = onceListeners && onceListeners[ listener ]; if ( isOnce ) { // remove listener // remove before trigger to prevent recursion this.off( eventName, listener ); // unset once flag delete onceListeners[ listener ]; } // trigger listener listener.apply( this, args ); // get next listener i += isOnce ? 0 : 1; listener = listeners[i]; } return this; }; return EvEmitter; })); /** * matchesSelector v2.0.1 * matchesSelector( element, '.selector' ) * MIT license */ /*jshint browser: true, strict: true, undef: true, unused: true */ ( function( window, factory ) { /*global define: false, module: false */ 'use strict'; // universal module definition if ( typeof define == 'function' && define.amd ) { // AMD define( 'desandro-matches-selector/matches-selector',factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory(); } else { // browser global window.matchesSelector = factory(); } }( window, function factory() { 'use strict'; var matchesMethod = ( function() { var ElemProto = Element.prototype; // check for the standard method name first if ( ElemProto.matches ) { return 'matches'; } // check un-prefixed if ( ElemProto.matchesSelector ) { return 'matchesSelector'; } // check vendor prefixes var prefixes = [ 'webkit', 'moz', 'ms', 'o' ]; for ( var i=0; i < prefixes.length; i++ ) { var prefix = prefixes[i]; var method = prefix + 'MatchesSelector'; if ( ElemProto[ method ] ) { return method; } } })(); return function matchesSelector( elem, selector ) { return elem[ matchesMethod ]( selector ); }; })); /** * Fizzy UI utils v2.0.1 * MIT license */ /*jshint browser: true, undef: true, unused: true, strict: true */ ( function( window, factory ) { // universal module definition /*jshint strict: false */ /*globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'fizzy-ui-utils/utils',[ 'desandro-matches-selector/matches-selector' ], function( matchesSelector ) { return factory( window, matchesSelector ); }); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( window, require('desandro-matches-selector') ); } else { // browser global window.fizzyUIUtils = factory( window, window.matchesSelector ); } }( window, function factory( window, matchesSelector ) { var utils = {}; // ----- extend ----- // // extends objects utils.extend = function( a, b ) { for ( var prop in b ) { a[ prop ] = b[ prop ]; } return a; }; // ----- modulo ----- // utils.modulo = function( num, div ) { return ( ( num % div ) + div ) % div; }; // ----- makeArray ----- // // turn element or nodeList into an array utils.makeArray = function( obj ) { var ary = []; if ( Array.isArray( obj ) ) { // use object if already an array ary = obj; } else if ( obj && typeof obj.length == 'number' ) { // convert nodeList to array for ( var i=0; i < obj.length; i++ ) { ary.push( obj[i] ); } } else { // array of single index ary.push( obj ); } return ary; }; // ----- removeFrom ----- // utils.removeFrom = function( ary, obj ) { var index = ary.indexOf( obj ); if ( index != -1 ) { ary.splice( index, 1 ); } }; // ----- getParent ----- // utils.getParent = function( elem, selector ) { while ( elem != document.body ) { elem = elem.parentNode; if ( matchesSelector( elem, selector ) ) { return elem; } } }; // ----- getQueryElement ----- // // use element as selector string utils.getQueryElement = function( elem ) { if ( typeof elem == 'string' ) { return document.querySelector( elem ); } return elem; }; // ----- handleEvent ----- // // enable .ontype to trigger from .addEventListener( elem, 'type' ) utils.handleEvent = function( event ) { var method = 'on' + event.type; if ( this[ method ] ) { this[ method ]( event ); } }; // ----- filterFindElements ----- // utils.filterFindElements = function( elems, selector ) { // make array of elems elems = utils.makeArray( elems ); var ffElems = []; elems.forEach( function( elem ) { // check that elem is an actual element if ( !( elem instanceof HTMLElement ) ) { return; } // add elem if no selector if ( !selector ) { ffElems.push( elem ); return; } // filter & find items if we have a selector // filter if ( matchesSelector( elem, selector ) ) { ffElems.push( elem ); } // find children var childElems = elem.querySelectorAll( selector ); // concat childElems to filterFound array for ( var i=0; i < childElems.length; i++ ) { ffElems.push( childElems[i] ); } }); return ffElems; }; // ----- debounceMethod ----- // utils.debounceMethod = function( _class, methodName, threshold ) { // original method var method = _class.prototype[ methodName ]; var timeoutName = methodName + 'Timeout'; _class.prototype[ methodName ] = function() { var timeout = this[ timeoutName ]; if ( timeout ) { clearTimeout( timeout ); } var args = arguments; var _this = this; this[ timeoutName ] = setTimeout( function() { method.apply( _this, args ); delete _this[ timeoutName ]; }, threshold || 100 ); }; }; // ----- docReady ----- // utils.docReady = function( callback ) { if ( document.readyState == 'complete' ) { callback(); } else { document.addEventListener( 'DOMContentLoaded', callback ); } }; // ----- htmlInit ----- // // http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/ utils.toDashed = function( str ) { return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) { return $1 + '-' + $2; }).toLowerCase(); }; var console = window.console; /** * allow user to initialize classes via [data-namespace] or .js-namespace class * htmlInit( Widget, 'widgetName' ) * options are parsed from data-namespace-options */ utils.htmlInit = function( WidgetClass, namespace ) { utils.docReady( function() { var dashedNamespace = utils.toDashed( namespace ); var dataAttr = 'data-' + dashedNamespace; var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' ); var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace ); var elems = utils.makeArray( dataAttrElems ) .concat( utils.makeArray( jsDashElems ) ); var dataOptionsAttr = dataAttr + '-options'; var jQuery = window.jQuery; elems.forEach( function( elem ) { var attr = elem.getAttribute( dataAttr ) || elem.getAttribute( dataOptionsAttr ); var options; try { options = attr && JSON.parse( attr ); } catch ( error ) { // log error, do not initialize if ( console ) { console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className + ': ' + error ); } return; } // initialize var instance = new WidgetClass( elem, options ); // make available via $().data('layoutname') if ( jQuery ) { jQuery.data( elem, namespace, instance ); } }); }); }; // ----- ----- // return utils; })); /** * Outlayer Item */ ( function( window, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD - RequireJS define( 'outlayer/item',[ 'ev-emitter/ev-emitter', 'get-size/get-size' ], factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS - Browserify, Webpack module.exports = factory( require('ev-emitter'), require('get-size') ); } else { // browser global window.Outlayer = {}; window.Outlayer.Item = factory( window.EvEmitter, window.getSize ); } }( window, function factory( EvEmitter, getSize ) { 'use strict'; // ----- helpers ----- // function isEmptyObj( obj ) { for ( var prop in obj ) { return false; } prop = null; return true; } // -------------------------- CSS3 support -------------------------- // var docElemStyle = document.documentElement.style; var transitionProperty = typeof docElemStyle.transition == 'string' ? 'transition' : 'WebkitTransition'; var transformProperty = typeof docElemStyle.transform == 'string' ? 'transform' : 'WebkitTransform'; var transitionEndEvent = { WebkitTransition: 'webkitTransitionEnd', transition: 'transitionend' }[ transitionProperty ]; // cache all vendor properties that could have vendor prefix var vendorProperties = { transform: transformProperty, transition: transitionProperty, transitionDuration: transitionProperty + 'Duration', transitionProperty: transitionProperty + 'Property', transitionDelay: transitionProperty + 'Delay' }; // -------------------------- Item -------------------------- // function Item( element, layout ) { if ( !element ) { return; } this.element = element; // parent layout class, i.e. Masonry, Isotope, or Packery this.layout = layout; this.position = { x: 0, y: 0 }; this._create(); } // inherit EvEmitter var proto = Item.prototype = Object.create( EvEmitter.prototype ); proto.constructor = Item; proto._create = function() { // transition objects this._transn = { ingProperties: {}, clean: {}, onEnd: {} }; this.css({ position: 'absolute' }); }; // trigger specified handler for event type proto.handleEvent = function( event ) { var method = 'on' + event.type; if ( this[ method ] ) { this[ method ]( event ); } }; proto.getSize = function() { this.size = getSize( this.element ); }; /** * apply CSS styles to element * @param {Object} style */ proto.css = function( style ) { var elemStyle = this.element.style; for ( var prop in style ) { // use vendor property if available var supportedProp = vendorProperties[ prop ] || prop; elemStyle[ supportedProp ] = style[ prop ]; } }; // measure position, and sets it proto.getPosition = function() { var style = getComputedStyle( this.element ); var isOriginLeft = this.layout._getOption('originLeft'); var isOriginTop = this.layout._getOption('originTop'); var xValue = style[ isOriginLeft ? 'left' : 'right' ]; var yValue = style[ isOriginTop ? 'top' : 'bottom' ]; // convert percent to pixels var layoutSize = this.layout.size; var x = xValue.indexOf('%') != -1 ? ( parseFloat( xValue ) / 100 ) * layoutSize.width : parseInt( xValue, 10 ); var y = yValue.indexOf('%') != -1 ? ( parseFloat( yValue ) / 100 ) * layoutSize.height : parseInt( yValue, 10 ); // clean up 'auto' or other non-integer values x = isNaN( x ) ? 0 : x; y = isNaN( y ) ? 0 : y; // remove padding from measurement x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight; y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom; this.position.x = x; this.position.y = y; }; // set settled position, apply padding proto.layoutPosition = function() { var layoutSize = this.layout.size; var style = {}; var isOriginLeft = this.layout._getOption('originLeft'); var isOriginTop = this.layout._getOption('originTop'); // x var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight'; var xProperty = isOriginLeft ? 'left' : 'right'; var xResetProperty = isOriginLeft ? 'right' : 'left'; var x = this.position.x + layoutSize[ xPadding ]; // set in percentage or pixels style[ xProperty ] = this.getXValue( x ); // reset other property style[ xResetProperty ] = ''; // y var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom'; var yProperty = isOriginTop ? 'top' : 'bottom'; var yResetProperty = isOriginTop ? 'bottom' : 'top'; var y = this.position.y + layoutSize[ yPadding ]; // set in percentage or pixels style[ yProperty ] = this.getYValue( y ); // reset other property style[ yResetProperty ] = ''; this.css( style ); this.emitEvent( 'layout', [ this ] ); }; proto.getXValue = function( x ) { var isHorizontal = this.layout._getOption('horizontal'); return this.layout.options.percentPosition && !isHorizontal ? ( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px'; }; proto.getYValue = function( y ) { var isHorizontal = this.layout._getOption('horizontal'); return this.layout.options.percentPosition && isHorizontal ? ( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px'; }; proto._transitionTo = function( x, y ) { this.getPosition(); // get current x & y from top/left var curX = this.position.x; var curY = this.position.y; var compareX = parseInt( x, 10 ); var compareY = parseInt( y, 10 ); var didNotMove = compareX === this.position.x && compareY === this.position.y; // save end position this.setPosition( x, y ); // if did not move and not transitioning, just go to layout if ( didNotMove && !this.isTransitioning ) { this.layoutPosition(); return; } var transX = x - curX; var transY = y - curY; var transitionStyle = {}; transitionStyle.transform = this.getTranslate( transX, transY ); this.transition({ to: transitionStyle, onTransitionEnd: { transform: this.layoutPosition }, isCleaning: true }); }; proto.getTranslate = function( x, y ) { // flip cooridinates if origin on right or bottom var isOriginLeft = this.layout._getOption('originLeft'); var isOriginTop = this.layout._getOption('originTop'); x = isOriginLeft ? x : -x; y = isOriginTop ? y : -y; return 'translate3d(' + x + 'px, ' + y + 'px, 0)'; }; // non transition + transform support proto.goTo = function( x, y ) { this.setPosition( x, y ); this.layoutPosition(); }; proto.moveTo = proto._transitionTo; proto.setPosition = function( x, y ) { this.position.x = parseInt( x, 10 ); this.position.y = parseInt( y, 10 ); }; // ----- transition ----- // /** * @param {Object} style - CSS * @param {Function} onTransitionEnd */ // non transition, just trigger callback proto._nonTransition = function( args ) { this.css( args.to ); if ( args.isCleaning ) { this._removeStyles( args.to ); } for ( var prop in args.onTransitionEnd ) { args.onTransitionEnd[ prop ].call( this ); } }; /** * proper transition * @param {Object} args - arguments * @param {Object} to - style to transition to * @param {Object} from - style to start transition from * @param {Boolean} isCleaning - removes transition styles after transition * @param {Function} onTransitionEnd - callback */ proto.transition = function( args ) { // redirect to nonTransition if no transition duration if ( !parseFloat( this.layout.options.transitionDuration ) ) { this._nonTransition( args ); return; } var _transition = this._transn; // keep track of onTransitionEnd callback by css property for ( var prop in args.onTransitionEnd ) { _transition.onEnd[ prop ] = args.onTransitionEnd[ prop ]; } // keep track of properties that are transitioning for ( prop in args.to ) { _transition.ingProperties[ prop ] = true; // keep track of properties to clean up when transition is done if ( args.isCleaning ) { _transition.clean[ prop ] = true; } } // set from styles if ( args.from ) { this.css( args.from ); // force redraw. http://blog.alexmaccaw.com/css-transitions var h = this.element.offsetHeight; // hack for JSHint to hush about unused var h = null; } // enable transition this.enableTransition( args.to ); // set styles that are transitioning this.css( args.to ); this.isTransitioning = true; }; // dash before all cap letters, including first for // WebkitTransform => -webkit-transform function toDashedAll( str ) { return str.replace( /([A-Z])/g, function( $1 ) { return '-' + $1.toLowerCase(); }); } var transitionProps = 'opacity,' + toDashedAll( transformProperty ); proto.enableTransition = function(/* style */) { // HACK changing transitionProperty during a transition // will cause transition to jump if ( this.isTransitioning ) { return; } // make `transition: foo, bar, baz` from style object // HACK un-comment this when enableTransition can work // while a transition is happening // var transitionValues = []; // for ( var prop in style ) { // // dash-ify camelCased properties like WebkitTransition // prop = vendorProperties[ prop ] || prop; // transitionValues.push( toDashedAll( prop ) ); // } // munge number to millisecond, to match stagger var duration = this.layout.options.transitionDuration; duration = typeof duration == 'number' ? duration + 'ms' : duration; // enable transition styles this.css({ transitionProperty: transitionProps, transitionDuration: duration, transitionDelay: this.staggerDelay || 0 }); // listen for transition end event this.element.addEventListener( transitionEndEvent, this, false ); }; // ----- events ----- // proto.onwebkitTransitionEnd = function( event ) { this.ontransitionend( event ); }; proto.onotransitionend = function( event ) { this.ontransitionend( event ); }; // properties that I munge to make my life easier var dashedVendorProperties = { '-webkit-transform': 'transform' }; proto.ontransitionend = function( event ) { // disregard bubbled events from children if ( event.target !== this.element ) { return; } var _transition = this._transn; // get property name of transitioned property, convert to prefix-free var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName; // remove property that has completed transitioning delete _transition.ingProperties[ propertyName ]; // check if any properties are still transitioning if ( isEmptyObj( _transition.ingProperties ) ) { // all properties have completed transitioning this.disableTransition(); } // clean style if ( propertyName in _transition.clean ) { // clean up style this.element.style[ event.propertyName ] = ''; delete _transition.clean[ propertyName ]; } // trigger onTransitionEnd callback if ( propertyName in _transition.onEnd ) { var onTransitionEnd = _transition.onEnd[ propertyName ]; onTransitionEnd.call( this ); delete _transition.onEnd[ propertyName ]; } this.emitEvent( 'transitionEnd', [ this ] ); }; proto.disableTransition = function() { this.removeTransitionStyles(); this.element.removeEventListener( transitionEndEvent, this, false ); this.isTransitioning = false; }; /** * removes style property from element * @param {Object} style **/ proto._removeStyles = function( style ) { // clean up transition styles var cleanStyle = {}; for ( var prop in style ) { cleanStyle[ prop ] = ''; } this.css( cleanStyle ); }; var cleanTransitionStyle = { transitionProperty: '', transitionDuration: '', transitionDelay: '' }; proto.removeTransitionStyles = function() { // remove transition this.css( cleanTransitionStyle ); }; // ----- stagger ----- // proto.stagger = function( delay ) { delay = isNaN( delay ) ? 0 : delay; this.staggerDelay = delay + 'ms'; }; // ----- show/hide/remove ----- // // remove element from DOM proto.removeElem = function() { this.element.parentNode.removeChild( this.element ); // remove display: none this.css({ display: '' }); this.emitEvent( 'remove', [ this ] ); }; proto.remove = function() { // just remove element if no transition support or no transition if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) { this.removeElem(); return; } // start transition this.once( 'transitionEnd', function() { this.removeElem(); }); this.hide(); }; proto.reveal = function() { delete this.isHidden; // remove display: none this.css({ display: '' }); var options = this.layout.options; var onTransitionEnd = {}; var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle'); onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd; this.transition({ from: options.hiddenStyle, to: options.visibleStyle, isCleaning: true, onTransitionEnd: onTransitionEnd }); }; proto.onRevealTransitionEnd = function() { // check if still visible // during transition, item may have been hidden if ( !this.isHidden ) { this.emitEvent('reveal'); } }; /** * get style property use for hide/reveal transition end * @param {String} styleProperty - hiddenStyle/visibleStyle * @returns {String} */ proto.getHideRevealTransitionEndProperty = function( styleProperty ) { var optionStyle = this.layout.options[ styleProperty ]; // use opacity if ( optionStyle.opacity ) { return 'opacity'; } // get first property for ( var prop in optionStyle ) { return prop; } }; proto.hide = function() { // set flag this.isHidden = true; // remove display: none this.css({ display: '' }); var options = this.layout.options; var onTransitionEnd = {}; var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle'); onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd; this.transition({ from: options.visibleStyle, to: options.hiddenStyle, // keep hidden stuff hidden isCleaning: true, onTransitionEnd: onTransitionEnd }); }; proto.onHideTransitionEnd = function() { // check if still hidden // during transition, item may have been un-hidden if ( this.isHidden ) { this.css({ display: 'none' }); this.emitEvent('hide'); } }; proto.destroy = function() { this.css({ position: '', left: '', right: '', top: '', bottom: '', transition: '', transform: '' }); }; return Item; })); /*! * Outlayer v2.1.0 * the brains and guts of a layout library * MIT license */ ( function( window, factory ) { 'use strict'; // universal module definition /* jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD - RequireJS define( 'outlayer/outlayer',[ 'ev-emitter/ev-emitter', 'get-size/get-size', 'fizzy-ui-utils/utils', './item' ], function( EvEmitter, getSize, utils, Item ) { return factory( window, EvEmitter, getSize, utils, Item); } ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS - Browserify, Webpack module.exports = factory( window, require('ev-emitter'), require('get-size'), require('fizzy-ui-utils'), require('./item') ); } else { // browser global window.Outlayer = factory( window, window.EvEmitter, window.getSize, window.fizzyUIUtils, window.Outlayer.Item ); } }( window, function factory( window, EvEmitter, getSize, utils, Item ) { 'use strict'; // ----- vars ----- // var console = window.console; var jQuery = window.jQuery; var noop = function() {}; // -------------------------- Outlayer -------------------------- // // globally unique identifiers var GUID = 0; // internal store of all Outlayer intances var instances = {}; /** * @param {Element, String} element * @param {Object} options * @constructor */ function Outlayer( element, options ) { var queryElement = utils.getQueryElement( element ); if ( !queryElement ) { if ( console ) { console.error( 'Bad element for ' + this.constructor.namespace + ': ' + ( queryElement || element ) ); } return; } this.element = queryElement; // add jQuery if ( jQuery ) { this.$element = jQuery( this.element ); } // options this.options = utils.extend( {}, this.constructor.defaults ); this.option( options ); // add id for Outlayer.getFromElement var id = ++GUID; this.element.outlayerGUID = id; // expando instances[ id ] = this; // associate via id // kick it off this._create(); var isInitLayout = this._getOption('initLayout'); if ( isInitLayout ) { this.layout(); } } // settings are for internal use only Outlayer.namespace = 'outlayer'; Outlayer.Item = Item; // default options Outlayer.defaults = { containerStyle: { position: 'relative' }, initLayout: true, originLeft: true, originTop: true, resize: true, resizeContainer: true, // item options transitionDuration: '0.4s', hiddenStyle: { opacity: 0, transform: 'scale(0.001)' }, visibleStyle: { opacity: 1, transform: 'scale(1)' } }; var proto = Outlayer.prototype; // inherit EvEmitter utils.extend( proto, EvEmitter.prototype ); /** * set options * @param {Object} opts */ proto.option = function( opts ) { utils.extend( this.options, opts ); }; /** * get backwards compatible option value, check old name */ proto._getOption = function( option ) { var oldOption = this.constructor.compatOptions[ option ]; return oldOption && this.options[ oldOption ] !== undefined ? this.options[ oldOption ] : this.options[ option ]; }; Outlayer.compatOptions = { // currentName: oldName initLayout: 'isInitLayout', horizontal: 'isHorizontal', layoutInstant: 'isLayoutInstant', originLeft: 'isOriginLeft', originTop: 'isOriginTop', resize: 'isResizeBound', resizeContainer: 'isResizingContainer' }; proto._create = function() { // get items from children this.reloadItems(); // elements that affect layout, but are not laid out this.stamps = []; this.stamp( this.options.stamp ); // set container style utils.extend( this.element.style, this.options.containerStyle ); // bind resize method var canBindResize = this._getOption('resize'); if ( canBindResize ) { this.bindResize(); } }; // goes through all children again and gets bricks in proper order proto.reloadItems = function() { // collection of item elements this.items = this._itemize( this.element.children ); }; /** * turn elements into Outlayer.Items to be used in layout * @param {Array or NodeList or HTMLElement} elems * @returns {Array} items - collection of new Outlayer Items */ proto._itemize = function( elems ) { var itemElems = this._filterFindItemElements( elems ); var Item = this.constructor.Item; // create new Outlayer Items for collection var items = []; for ( var i=0; i < itemElems.length; i++ ) { var elem = itemElems[i]; var item = new Item( elem, this ); items.push( item ); } return items; }; /** * get item elements to be used in layout * @param {Array or NodeList or HTMLElement} elems * @returns {Array} items - item elements */ proto._filterFindItemElements = function( elems ) { return utils.filterFindElements( elems, this.options.itemSelector ); }; /** * getter method for getting item elements * @returns {Array} elems - collection of item elements */ proto.getItemElements = function() { return this.items.map( function( item ) { return item.element; }); }; // ----- init & layout ----- // /** * lays out all items */ proto.layout = function() { this._resetLayout(); this._manageStamps(); // don't animate first layout var layoutInstant = this._getOption('layoutInstant'); var isInstant = layoutInstant !== undefined ? layoutInstant : !this._isLayoutInited; this.layoutItems( this.items, isInstant ); // flag for initalized this._isLayoutInited = true; }; // _init is alias for layout proto._init = proto.layout; /** * logic before any new layout */ proto._resetLayout = function() { this.getSize(); }; proto.getSize = function() { this.size = getSize( this.element ); }; /** * get measurement from option, for columnWidth, rowHeight, gutter * if option is String -> get element from selector string, & get size of element * if option is Element -> get size of element * else use option as a number * * @param {String} measurement * @param {String} size - width or height * @private */ proto._getMeasurement = function( measurement, size ) { var option = this.options[ measurement ]; var elem; if ( !option ) { // default to 0 this[ measurement ] = 0; } else { // use option as an element if ( typeof option == 'string' ) { elem = this.element.querySelector( option ); } else if ( option instanceof HTMLElement ) { elem = option; } // use size of element, if element this[ measurement ] = elem ? getSize( elem )[ size ] : option; } }; /** * layout a collection of item elements * @api public */ proto.layoutItems = function( items, isInstant ) { items = this._getItemsForLayout( items ); this._layoutItems( items, isInstant ); this._postLayout(); }; /** * get the items to be laid out * you may want to skip over some items * @param {Array} items * @returns {Array} items */ proto._getItemsForLayout = function( items ) { return items.filter( function( item ) { return !item.isIgnored; }); }; /** * layout items * @param {Array} items * @param {Boolean} isInstant */ proto._layoutItems = function( items, isInstant ) { this._emitCompleteOnItems( 'layout', items ); if ( !items || !items.length ) { // no items, emit event with empty array return; } var queue = []; items.forEach( function( item ) { // get x/y object from method var position = this._getItemLayoutPosition( item ); // enqueue position.item = item; position.isInstant = isInstant || item.isLayoutInstant; queue.push( position ); }, this ); this._processLayoutQueue( queue ); }; /** * get item layout position * @param {Outlayer.Item} item * @returns {Object} x and y position */ proto._getItemLayoutPosition = function( /* item */ ) { return { x: 0, y: 0 }; }; /** * iterate over array and position each item * Reason being - separating this logic prevents 'layout invalidation' * thx @paul_irish * @param {Array} queue */ proto._processLayoutQueue = function( queue ) { this.updateStagger(); queue.forEach( function( obj, i ) { this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i ); }, this ); }; // set stagger from option in milliseconds number proto.updateStagger = function() { var stagger = this.options.stagger; if ( stagger === null || stagger === undefined ) { this.stagger = 0; return; } this.stagger = getMilliseconds( stagger ); return this.stagger; }; /** * Sets position of item in DOM * @param {Outlayer.Item} item * @param {Number} x - horizontal position * @param {Number} y - vertical position * @param {Boolean} isInstant - disables transitions */ proto._positionItem = function( item, x, y, isInstant, i ) { if ( isInstant ) { // if not transition, just set CSS item.goTo( x, y ); } else { item.stagger( i * this.stagger ); item.moveTo( x, y ); } }; /** * Any logic you want to do after each layout, * i.e. size the container */ proto._postLayout = function() { this.resizeContainer(); }; proto.resizeContainer = function() { var isResizingContainer = this._getOption('resizeContainer'); if ( !isResizingContainer ) { return; } var size = this._getContainerSize(); if ( size ) { this._setContainerMeasure( size.width, true ); this._setContainerMeasure( size.height, false ); } }; /** * Sets width or height of container if returned * @returns {Object} size * @param {Number} width * @param {Number} height */ proto._getContainerSize = noop; /** * @param {Number} measure - size of width or height * @param {Boolean} isWidth */ proto._setContainerMeasure = function( measure, isWidth ) { if ( measure === undefined ) { return; } var elemSize = this.size; // add padding and border width if border box if ( elemSize.isBorderBox ) { measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight + elemSize.borderLeftWidth + elemSize.borderRightWidth : elemSize.paddingBottom + elemSize.paddingTop + elemSize.borderTopWidth + elemSize.borderBottomWidth; } measure = Math.max( measure, 0 ); this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px'; }; /** * emit eventComplete on a collection of items events * @param {String} eventName * @param {Array} items - Outlayer.Items */ proto._emitCompleteOnItems = function( eventName, items ) { var _this = this; function onComplete() { _this.dispatchEvent( eventName + 'Complete', null, [ items ] ); } var count = items.length; if ( !items || !count ) { onComplete(); return; } var doneCount = 0; function tick() { doneCount++; if ( doneCount == count ) { onComplete(); } } // bind callback items.forEach( function( item ) { item.once( eventName, tick ); }); }; /** * emits events via EvEmitter and jQuery events * @param {String} type - name of event * @param {Event} event - original event * @param {Array} args - extra arguments */ proto.dispatchEvent = function( type, event, args ) { // add original event to arguments var emitArgs = event ? [ event ].concat( args ) : args; this.emitEvent( type, emitArgs ); if ( jQuery ) { // set this.$element this.$element = this.$element || jQuery( this.element ); if ( event ) { // create jQuery event var $event = jQuery.Event( event ); $event.type = type; this.$element.trigger( $event, args ); } else { // just trigger with type if no event available this.$element.trigger( type, args ); } } }; // -------------------------- ignore & stamps -------------------------- // /** * keep item in collection, but do not lay it out * ignored items do not get skipped in layout * @param {Element} elem */ proto.ignore = function( elem ) { var item = this.getItem( elem ); if ( item ) { item.isIgnored = true; } }; /** * return item to layout collection * @param {Element} elem */ proto.unignore = function( elem ) { var item = this.getItem( elem ); if ( item ) { delete item.isIgnored; } }; /** * adds elements to stamps * @param {NodeList, Array, Element, or String} elems */ proto.stamp = function( elems ) { elems = this._find( elems ); if ( !elems ) { return; } this.stamps = this.stamps.concat( elems ); // ignore elems.forEach( this.ignore, this ); }; /** * removes elements to stamps * @param {NodeList, Array, or Element} elems */ proto.unstamp = function( elems ) { elems = this._find( elems ); if ( !elems ){ return; } elems.forEach( function( elem ) { // filter out removed stamp elements utils.removeFrom( this.stamps, elem ); this.unignore( elem ); }, this ); }; /** * finds child elements * @param {NodeList, Array, Element, or String} elems * @returns {Array} elems */ proto._find = function( elems ) { if ( !elems ) { return; } // if string, use argument as selector string if ( typeof elems == 'string' ) { elems = this.element.querySelectorAll( elems ); } elems = utils.makeArray( elems ); return elems; }; proto._manageStamps = function() { if ( !this.stamps || !this.stamps.length ) { return; } this._getBoundingRect(); this.stamps.forEach( this._manageStamp, this ); }; // update boundingLeft / Top proto._getBoundingRect = function() { // get bounding rect for container element var boundingRect = this.element.getBoundingClientRect(); var size = this.size; this._boundingRect = { left: boundingRect.left + size.paddingLeft + size.borderLeftWidth, top: boundingRect.top + size.paddingTop + size.borderTopWidth, right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ), bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth ) }; }; /** * @param {Element} stamp **/ proto._manageStamp = noop; /** * get x/y position of element relative to container element * @param {Element} elem * @returns {Object} offset - has left, top, right, bottom */ proto._getElementOffset = function( elem ) { var boundingRect = elem.getBoundingClientRect(); var thisRect = this._boundingRect; var size = getSize( elem ); var offset = { left: boundingRect.left - thisRect.left - size.marginLeft, top: boundingRect.top - thisRect.top - size.marginTop, right: thisRect.right - boundingRect.right - size.marginRight, bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom }; return offset; }; // -------------------------- resize -------------------------- // // enable event handlers for listeners // i.e. resize -> onresize proto.handleEvent = utils.handleEvent; /** * Bind layout to window resizing */ proto.bindResize = function() { window.addEventListener( 'resize', this ); this.isResizeBound = true; }; /** * Unbind layout to window resizing */ proto.unbindResize = function() { window.removeEventListener( 'resize', this ); this.isResizeBound = false; }; proto.onresize = function() { this.resize(); }; utils.debounceMethod( Outlayer, 'onresize', 100 ); proto.resize = function() { // don't trigger if size did not change // or if resize was unbound. See #9 if ( !this.isResizeBound || !this.needsResizeLayout() ) { return; } this.layout(); }; /** * check if layout is needed post layout * @returns Boolean */ proto.needsResizeLayout = function() { var size = getSize( this.element ); // check that this.size and size are there // IE8 triggers resize on body size change, so they might not be var hasSizes = this.size && size; return hasSizes && size.innerWidth !== this.size.innerWidth; }; // -------------------------- methods -------------------------- // /** * add items to Outlayer instance * @param {Array or NodeList or Element} elems * @returns {Array} items - Outlayer.Items **/ proto.addItems = function( elems ) { var items = this._itemize( elems ); // add items to collection if ( items.length ) { this.items = this.items.concat( items ); } return items; }; /** * Layout newly-appended item elements * @param {Array or NodeList or Element} elems */ proto.appended = function( elems ) { var items = this.addItems( elems ); if ( !items.length ) { return; } // layout and reveal just the new items this.layoutItems( items, true ); this.reveal( items ); }; /** * Layout prepended elements * @param {Array or NodeList or Element} elems */ proto.prepended = function( elems ) { var items = this._itemize( elems ); if ( !items.length ) { return; } // add items to beginning of collection var previousItems = this.items.slice(0); this.items = items.concat( previousItems ); // start new layout this._resetLayout(); this._manageStamps(); // layout new stuff without transition this.layoutItems( items, true ); this.reveal( items ); // layout previous items this.layoutItems( previousItems ); }; /** * reveal a collection of items * @param {Array of Outlayer.Items} items */ proto.reveal = function( items ) { this._emitCompleteOnItems( 'reveal', items ); if ( !items || !items.length ) { return; } var stagger = this.updateStagger(); items.forEach( function( item, i ) { item.stagger( i * stagger ); item.reveal(); }); }; /** * hide a collection of items * @param {Array of Outlayer.Items} items */ proto.hide = function( items ) { this._emitCompleteOnItems( 'hide', items ); if ( !items || !items.length ) { return; } var stagger = this.updateStagger(); items.forEach( function( item, i ) { item.stagger( i * stagger ); item.hide(); }); }; /** * reveal item elements * @param {Array}, {Element}, {NodeList} items */ proto.revealItemElements = function( elems ) { var items = this.getItems( elems ); this.reveal( items ); }; /** * hide item elements * @param {Array}, {Element}, {NodeList} items */ proto.hideItemElements = function( elems ) { var items = this.getItems( elems ); this.hide( items ); }; /** * get Outlayer.Item, given an Element * @param {Element} elem * @param {Function} callback * @returns {Outlayer.Item} item */ proto.getItem = function( elem ) { // loop through items to get the one that matches for ( var i=0; i < this.items.length; i++ ) { var item = this.items[i]; if ( item.element == elem ) { // return item return item; } } }; /** * get collection of Outlayer.Items, given Elements * @param {Array} elems * @returns {Array} items - Outlayer.Items */ proto.getItems = function( elems ) { elems = utils.makeArray( elems ); var items = []; elems.forEach( function( elem ) { var item = this.getItem( elem ); if ( item ) { items.push( item ); } }, this ); return items; }; /** * remove element(s) from instance and DOM * @param {Array or NodeList or Element} elems */ proto.remove = function( elems ) { var removeItems = this.getItems( elems ); this._emitCompleteOnItems( 'remove', removeItems ); // bail if no items to remove if ( !removeItems || !removeItems.length ) { return; } removeItems.forEach( function( item ) { item.remove(); // remove item from collection utils.removeFrom( this.items, item ); }, this ); }; // ----- destroy ----- // // remove and disable Outlayer instance proto.destroy = function() { // clean up dynamic styles var style = this.element.style; style.height = ''; style.position = ''; style.width = ''; // destroy items this.items.forEach( function( item ) { item.destroy(); }); this.unbindResize(); var id = this.element.outlayerGUID; delete instances[ id ]; // remove reference to instance by id delete this.element.outlayerGUID; // remove data for jQuery if ( jQuery ) { jQuery.removeData( this.element, this.constructor.namespace ); } }; // -------------------------- data -------------------------- // /** * get Outlayer instance from element * @param {Element} elem * @returns {Outlayer} */ Outlayer.data = function( elem ) { elem = utils.getQueryElement( elem ); var id = elem && elem.outlayerGUID; return id && instances[ id ]; }; // -------------------------- create Outlayer class -------------------------- // /** * create a layout class * @param {String} namespace */ Outlayer.create = function( namespace, options ) { // sub-class Outlayer var Layout = subclass( Outlayer ); // apply new options and compatOptions Layout.defaults = utils.extend( {}, Outlayer.defaults ); utils.extend( Layout.defaults, options ); Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions ); Layout.namespace = namespace; Layout.data = Outlayer.data; // sub-class Item Layout.Item = subclass( Item ); // -------------------------- declarative -------------------------- // utils.htmlInit( Layout, namespace ); // -------------------------- jQuery bridge -------------------------- // // make into jQuery plugin if ( jQuery && jQuery.bridget ) { jQuery.bridget( namespace, Layout ); } return Layout; }; function subclass( Parent ) { function SubClass() { Parent.apply( this, arguments ); } SubClass.prototype = Object.create( Parent.prototype ); SubClass.prototype.constructor = SubClass; return SubClass; } // ----- helpers ----- // // how many milliseconds are in each unit var msUnits = { ms: 1, s: 1000 }; // munge time-like parameter into millisecond number // '0.4s' -> 40 function getMilliseconds( time ) { if ( typeof time == 'number' ) { return time; } var matches = time.match( /(^\d*\.?\d*)(\w*)/ ); var num = matches && matches[1]; var unit = matches && matches[2]; if ( !num.length ) { return 0; } num = parseFloat( num ); var mult = msUnits[ unit ] || 1; return num * mult; } // ----- fin ----- // // back in global Outlayer.Item = Item; return Outlayer; })); /** * Rect * low-level utility class for basic geometry */ ( function( window, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'packery/js/rect',factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory(); } else { // browser global window.Packery = window.Packery || {}; window.Packery.Rect = factory(); } }( window, function factory() { 'use strict'; // -------------------------- Rect -------------------------- // function Rect( props ) { // extend properties from defaults for ( var prop in Rect.defaults ) { this[ prop ] = Rect.defaults[ prop ]; } for ( prop in props ) { this[ prop ] = props[ prop ]; } } Rect.defaults = { x: 0, y: 0, width: 0, height: 0 }; var proto = Rect.prototype; /** * Determines whether or not this rectangle wholly encloses another rectangle or point. * @param {Rect} rect * @returns {Boolean} **/ proto.contains = function( rect ) { // points don't have width or height var otherWidth = rect.width || 0; var otherHeight = rect.height || 0; return this.x <= rect.x && this.y <= rect.y && this.x + this.width >= rect.x + otherWidth && this.y + this.height >= rect.y + otherHeight; }; /** * Determines whether or not the rectangle intersects with another. * @param {Rect} rect * @returns {Boolean} **/ proto.overlaps = function( rect ) { var thisRight = this.x + this.width; var thisBottom = this.y + this.height; var rectRight = rect.x + rect.width; var rectBottom = rect.y + rect.height; // http://stackoverflow.com/a/306332 return this.x < rectRight && thisRight > rect.x && this.y < rectBottom && thisBottom > rect.y; }; /** * @param {Rect} rect - the overlapping rect * @returns {Array} freeRects - rects representing the area around the rect **/ proto.getMaximalFreeRects = function( rect ) { // if no intersection, return false if ( !this.overlaps( rect ) ) { return false; } var freeRects = []; var freeRect; var thisRight = this.x + this.width; var thisBottom = this.y + this.height; var rectRight = rect.x + rect.width; var rectBottom = rect.y + rect.height; // top if ( this.y < rect.y ) { freeRect = new Rect({ x: this.x, y: this.y, width: this.width, height: rect.y - this.y }); freeRects.push( freeRect ); } // right if ( thisRight > rectRight ) { freeRect = new Rect({ x: rectRight, y: this.y, width: thisRight - rectRight, height: this.height }); freeRects.push( freeRect ); } // bottom if ( thisBottom > rectBottom ) { freeRect = new Rect({ x: this.x, y: rectBottom, width: this.width, height: thisBottom - rectBottom }); freeRects.push( freeRect ); } // left if ( this.x < rect.x ) { freeRect = new Rect({ x: this.x, y: this.y, width: rect.x - this.x, height: this.height }); freeRects.push( freeRect ); } return freeRects; }; proto.canFit = function( rect ) { return this.width >= rect.width && this.height >= rect.height; }; return Rect; })); /** * Packer * bin-packing algorithm */ ( function( window, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'packery/js/packer',[ './rect' ], factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( require('./rect') ); } else { // browser global var Packery = window.Packery = window.Packery || {}; Packery.Packer = factory( Packery.Rect ); } }( window, function factory( Rect ) { 'use strict'; // -------------------------- Packer -------------------------- // /** * @param {Number} width * @param {Number} height * @param {String} sortDirection * topLeft for vertical, leftTop for horizontal */ function Packer( width, height, sortDirection ) { this.width = width || 0; this.height = height || 0; this.sortDirection = sortDirection || 'downwardLeftToRight'; this.reset(); } var proto = Packer.prototype; proto.reset = function() { this.spaces = []; var initialSpace = new Rect({ x: 0, y: 0, width: this.width, height: this.height }); this.spaces.push( initialSpace ); // set sorter this.sorter = sorters[ this.sortDirection ] || sorters.downwardLeftToRight; }; // change x and y of rect to fit with in Packer's available spaces proto.pack = function( rect ) { for ( var i=0; i < this.spaces.length; i++ ) { var space = this.spaces[i]; if ( space.canFit( rect ) ) { this.placeInSpace( rect, space ); break; } } }; proto.columnPack = function( rect ) { for ( var i=0; i < this.spaces.length; i++ ) { var space = this.spaces[i]; var canFitInSpaceColumn = space.x <= rect.x && space.x + space.width >= rect.x + rect.width && space.height >= rect.height - 0.01; // fudge number for rounding error if ( canFitInSpaceColumn ) { rect.y = space.y; this.placed( rect ); break; } } }; proto.rowPack = function( rect ) { for ( var i=0; i < this.spaces.length; i++ ) { var space = this.spaces[i]; var canFitInSpaceRow = space.y <= rect.y && space.y + space.height >= rect.y + rect.height && space.width >= rect.width - 0.01; // fudge number for rounding error if ( canFitInSpaceRow ) { rect.x = space.x; this.placed( rect ); break; } } }; proto.placeInSpace = function( rect, space ) { // place rect in space rect.x = space.x; rect.y = space.y; this.placed( rect ); }; // update spaces with placed rect proto.placed = function( rect ) { // update spaces var revisedSpaces = []; for ( var i=0; i < this.spaces.length; i++ ) { var space = this.spaces[i]; var newSpaces = space.getMaximalFreeRects( rect ); // add either the original space or the new spaces to the revised spaces if ( newSpaces ) { revisedSpaces.push.apply( revisedSpaces, newSpaces ); } else { revisedSpaces.push( space ); } } this.spaces = revisedSpaces; this.mergeSortSpaces(); }; proto.mergeSortSpaces = function() { // remove redundant spaces Packer.mergeRects( this.spaces ); this.spaces.sort( this.sorter ); }; // add a space back proto.addSpace = function( rect ) { this.spaces.push( rect ); this.mergeSortSpaces(); }; // -------------------------- utility functions -------------------------- // /** * Remove redundant rectangle from array of rectangles * @param {Array} rects: an array of Rects * @returns {Array} rects: an array of Rects **/ Packer.mergeRects = function( rects ) { var i = 0; var rect = rects[i]; rectLoop: while ( rect ) { var j = 0; var compareRect = rects[ i + j ]; while ( compareRect ) { if ( compareRect == rect ) { j++; // next } else if ( compareRect.contains( rect ) ) { // remove rect rects.splice( i, 1 ); rect = rects[i]; // set next rect continue rectLoop; // bail on compareLoop } else if ( rect.contains( compareRect ) ) { // remove compareRect rects.splice( i + j, 1 ); } else { j++; } compareRect = rects[ i + j ]; // set next compareRect } i++; rect = rects[i]; } return rects; }; // -------------------------- sorters -------------------------- // // functions for sorting rects in order var sorters = { // top down, then left to right downwardLeftToRight: function( a, b ) { return a.y - b.y || a.x - b.x; }, // left to right, then top down rightwardTopToBottom: function( a, b ) { return a.x - b.x || a.y - b.y; } }; // -------------------------- -------------------------- // return Packer; })); /** * Packery Item Element **/ ( function( window, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD define( 'packery/js/item',[ 'outlayer/outlayer', './rect' ], factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( require('outlayer'), require('./rect') ); } else { // browser global window.Packery.Item = factory( window.Outlayer, window.Packery.Rect ); } }( window, function factory( Outlayer, Rect ) { 'use strict'; // -------------------------- Item -------------------------- // var docElemStyle = document.documentElement.style; var transformProperty = typeof docElemStyle.transform == 'string' ? 'transform' : 'WebkitTransform'; // sub-class Item var Item = function PackeryItem() { Outlayer.Item.apply( this, arguments ); }; var proto = Item.prototype = Object.create( Outlayer.Item.prototype ); var __create = proto._create; proto._create = function() { // call default _create logic __create.call( this ); this.rect = new Rect(); }; var _moveTo = proto.moveTo; proto.moveTo = function( x, y ) { // don't shift 1px while dragging var dx = Math.abs( this.position.x - x ); var dy = Math.abs( this.position.y - y ); var canHackGoTo = this.layout.dragItemCount && !this.isPlacing && !this.isTransitioning && dx < 1 && dy < 1; if ( canHackGoTo ) { this.goTo( x, y ); return; } _moveTo.apply( this, arguments ); }; // -------------------------- placing -------------------------- // proto.enablePlacing = function() { this.removeTransitionStyles(); // remove transform property from transition if ( this.isTransitioning && transformProperty ) { this.element.style[ transformProperty ] = 'none'; } this.isTransitioning = false; this.getSize(); this.layout._setRectSize( this.element, this.rect ); this.isPlacing = true; }; proto.disablePlacing = function() { this.isPlacing = false; }; // ----- ----- // // remove element from DOM proto.removeElem = function() { this.element.parentNode.removeChild( this.element ); // add space back to packer this.layout.packer.addSpace( this.rect ); this.emitEvent( 'remove', [ this ] ); }; // ----- dropPlaceholder ----- // proto.showDropPlaceholder = function() { var dropPlaceholder = this.dropPlaceholder; if ( !dropPlaceholder ) { // create dropPlaceholder dropPlaceholder = this.dropPlaceholder = document.createElement('div'); dropPlaceholder.className = 'packery-drop-placeholder'; dropPlaceholder.style.position = 'absolute'; } dropPlaceholder.style.width = this.size.width + 'px'; dropPlaceholder.style.height = this.size.height + 'px'; this.positionDropPlaceholder(); this.layout.element.appendChild( dropPlaceholder ); }; proto.positionDropPlaceholder = function() { this.dropPlaceholder.style[ transformProperty ] = 'translate(' + this.rect.x + 'px, ' + this.rect.y + 'px)'; }; proto.hideDropPlaceholder = function() { // only remove once, #333 var parent = this.dropPlaceholder.parentNode; if ( parent ) { parent.removeChild( this.dropPlaceholder ); } }; // ----- ----- // return Item; })); /*! * Packery v2.1.1 * Gapless, draggable grid layouts * * Licensed GPLv3 for open source use * or Packery Commercial License for commercial use * * http://packery.metafizzy.co * Copyright 2016 Metafizzy */ ( function( window, factory ) { // universal module definition /* jshint strict: false */ /* globals define, module, require */ if ( typeof define == 'function' && define.amd ) { // AMD define( [ 'get-size/get-size', 'outlayer/outlayer', 'packery/js/rect', 'packery/js/packer', 'packery/js/item' ], factory ); } else if ( typeof module == 'object' && module.exports ) { // CommonJS module.exports = factory( require('get-size'), require('outlayer'), require('./rect'), require('./packer'), require('./item') ); } else { // browser global window.Packery = factory( window.getSize, window.Outlayer, window.Packery.Rect, window.Packery.Packer, window.Packery.Item ); } }( window, function factory( getSize, Outlayer, Rect, Packer, Item ) { 'use strict'; // ----- Rect ----- // // allow for pixel rounding errors IE8-IE11 & Firefox; #227 Rect.prototype.canFit = function( rect ) { return this.width >= rect.width - 1 && this.height >= rect.height - 1; }; // -------------------------- Packery -------------------------- // // create an Outlayer layout class var Packery = Outlayer.create('packery'); Packery.Item = Item; var proto = Packery.prototype; proto._create = function() { // call super Outlayer.prototype._create.call( this ); // initial properties this.packer = new Packer(); // packer for drop targets this.shiftPacker = new Packer(); this.isEnabled = true; this.dragItemCount = 0; // create drag handlers var _this = this; this.handleDraggabilly = { dragStart: function() { _this.itemDragStart( this.element ); }, dragMove: function() { _this.itemDragMove( this.element, this.position.x, this.position.y ); }, dragEnd: function() { _this.itemDragEnd( this.element ); } }; this.handleUIDraggable = { start: function handleUIDraggableStart( event, ui ) { // HTML5 may trigger dragstart, dismiss HTML5 dragging if ( !ui ) { return; } _this.itemDragStart( event.currentTarget ); }, drag: function handleUIDraggableDrag( event, ui ) { if ( !ui ) { return; } _this.itemDragMove( event.currentTarget, ui.position.left, ui.position.top ); }, stop: function handleUIDraggableStop( event, ui ) { if ( !ui ) { return; } _this.itemDragEnd( event.currentTarget ); } }; }; // ----- init & layout ----- // /** * logic before any new layout */ proto._resetLayout = function() { this.getSize(); this._getMeasurements(); // reset packer var width, height, sortDirection; // packer settings, if horizontal or vertical if ( this._getOption('horizontal') ) { width = Infinity; height = this.size.innerHeight + this.gutter; sortDirection = 'rightwardTopToBottom'; } else { width = this.size.innerWidth + this.gutter; height = Infinity; sortDirection = 'downwardLeftToRight'; } this.packer.width = this.shiftPacker.width = width; this.packer.height = this.shiftPacker.height = height; this.packer.sortDirection = this.shiftPacker.sortDirection = sortDirection; this.packer.reset(); // layout this.maxY = 0; this.maxX = 0; }; /** * update columnWidth, rowHeight, & gutter * @private */ proto._getMeasurements = function() { this._getMeasurement( 'columnWidth', 'width' ); this._getMeasurement( 'rowHeight', 'height' ); this._getMeasurement( 'gutter', 'width' ); }; proto._getItemLayoutPosition = function( item ) { this._setRectSize( item.element, item.rect ); if ( this.isShifting || this.dragItemCount > 0 ) { var packMethod = this._getPackMethod(); this.packer[ packMethod ]( item.rect ); } else { this.packer.pack( item.rect ); } this._setMaxXY( item.rect ); return item.rect; }; proto.shiftLayout = function() { this.isShifting = true; this.layout(); delete this.isShifting; }; proto._getPackMethod = function() { return this._getOption('horizontal') ? 'rowPack' : 'columnPack'; }; /** * set max X and Y value, for size of container * @param {Packery.Rect} rect * @private */ proto._setMaxXY = function( rect ) { this.maxX = Math.max( rect.x + rect.width, this.maxX ); this.maxY = Math.max( rect.y + rect.height, this.maxY ); }; /** * set the width and height of a rect, applying columnWidth and rowHeight * @param {Element} elem * @param {Packery.Rect} rect */ proto._setRectSize = function( elem, rect ) { var size = getSize( elem ); var w = size.outerWidth; var h = size.outerHeight; // size for columnWidth and rowHeight, if available // only check if size is non-zero, #177 if ( w || h ) { w = this._applyGridGutter( w, this.columnWidth ); h = this._applyGridGutter( h, this.rowHeight ); } // rect must fit in packer rect.width = Math.min( w, this.packer.width ); rect.height = Math.min( h, this.packer.height ); }; /** * fits item to columnWidth/rowHeight and adds gutter * @param {Number} measurement - item width or height * @param {Number} gridSize - columnWidth or rowHeight * @returns measurement */ proto._applyGridGutter = function( measurement, gridSize ) { // just add gutter if no gridSize if ( !gridSize ) { return measurement + this.gutter; } gridSize += this.gutter; // fit item to columnWidth/rowHeight var remainder = measurement % gridSize; var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil'; measurement = Math[ mathMethod ]( measurement / gridSize ) * gridSize; return measurement; }; proto._getContainerSize = function() { if ( this._getOption('horizontal') ) { return { width: this.maxX - this.gutter }; } else { return { height: this.maxY - this.gutter }; } }; // -------------------------- stamp -------------------------- // /** * makes space for element * @param {Element} elem */ proto._manageStamp = function( elem ) { var item = this.getItem( elem ); var rect; if ( item && item.isPlacing ) { rect = item.rect; } else { var offset = this._getElementOffset( elem ); rect = new Rect({ x: this._getOption('originLeft') ? offset.left : offset.right, y: this._getOption('originTop') ? offset.top : offset.bottom }); } this._setRectSize( elem, rect ); // save its space in the packer this.packer.placed( rect ); this._setMaxXY( rect ); }; // -------------------------- methods -------------------------- // function verticalSorter( a, b ) { return a.position.y - b.position.y || a.position.x - b.position.x; } function horizontalSorter( a, b ) { return a.position.x - b.position.x || a.position.y - b.position.y; } proto.sortItemsByPosition = function() { var sorter = this._getOption('horizontal') ? horizontalSorter : verticalSorter; this.items.sort( sorter ); }; /** * Fit item element in its current position * Packery will position elements around it * useful for expanding elements * * @param {Element} elem * @param {Number} x - horizontal destination position, optional * @param {Number} y - vertical destination position, optional */ proto.fit = function( elem, x, y ) { var item = this.getItem( elem ); if ( !item ) { return; } // stamp item to get it out of layout this.stamp( item.element ); // set placing flag item.enablePlacing(); this.updateShiftTargets( item ); // fall back to current position for fitting x = x === undefined ? item.rect.x: x; y = y === undefined ? item.rect.y: y; // position it best at its destination this.shift( item, x, y ); this._bindFitEvents( item ); item.moveTo( item.rect.x, item.rect.y ); // layout everything else this.shiftLayout(); // return back to regularly scheduled programming this.unstamp( item.element ); this.sortItemsByPosition(); item.disablePlacing(); }; /** * emit event when item is fit and other items are laid out * @param {Packery.Item} item * @private */ proto._bindFitEvents = function( item ) { var _this = this; var ticks = 0; function onLayout() { ticks++; if ( ticks != 2 ) { return; } _this.dispatchEvent( 'fitComplete', null, [ item ] ); } // when item is laid out item.once( 'layout', onLayout ); // when all items are laid out this.once( 'layoutComplete', onLayout ); }; // -------------------------- resize -------------------------- // // debounced, layout on resize proto.resize = function() { // don't trigger if size did not change // or if resize was unbound. See #285, outlayer#9 if ( !this.isResizeBound || !this.needsResizeLayout() ) { return; } if ( this.options.shiftPercentResize ) { this.resizeShiftPercentLayout(); } else { this.layout(); } }; /** * check if layout is needed post layout * @returns Boolean */ proto.needsResizeLayout = function() { var size = getSize( this.element ); var innerSize = this._getOption('horizontal') ? 'innerHeight' : 'innerWidth'; return size[ innerSize ] != this.size[ innerSize ]; }; proto.resizeShiftPercentLayout = function() { var items = this._getItemsForLayout( this.items ); var isHorizontal = this._getOption('horizontal'); var coord = isHorizontal ? 'y' : 'x'; var measure = isHorizontal ? 'height' : 'width'; var segmentName = isHorizontal ? 'rowHeight' : 'columnWidth'; var innerSize = isHorizontal ? 'innerHeight' : 'innerWidth'; // proportional re-align items var previousSegment = this[ segmentName ]; previousSegment = previousSegment && previousSegment + this.gutter; if ( previousSegment ) { this._getMeasurements(); var currentSegment = this[ segmentName ] + this.gutter; items.forEach( function( item ) { var seg = Math.round( item.rect[ coord ] / previousSegment ); item.rect[ coord ] = seg * currentSegment; }); } else { var currentSize = getSize( this.element )[ innerSize ] + this.gutter; var previousSize = this.packer[ measure ]; items.forEach( function( item ) { item.rect[ coord ] = ( item.rect[ coord ] / previousSize ) * currentSize; }); } this.shiftLayout(); }; // -------------------------- drag -------------------------- // /** * handle an item drag start event * @param {Element} elem */ proto.itemDragStart = function( elem ) { if ( !this.isEnabled ) { return; } this.stamp( elem ); // this.ignore( elem ); var item = this.getItem( elem ); if ( !item ) { return; } item.enablePlacing(); item.showDropPlaceholder(); this.dragItemCount++; this.updateShiftTargets( item ); }; proto.updateShiftTargets = function( dropItem ) { this.shiftPacker.reset(); // pack stamps this._getBoundingRect(); var isOriginLeft = this._getOption('originLeft'); var isOriginTop = this._getOption('originTop'); this.stamps.forEach( function( stamp ) { // ignore dragged item var item = this.getItem( stamp ); if ( item && item.isPlacing ) { return; } var offset = this._getElementOffset( stamp ); var rect = new Rect({ x: isOriginLeft ? offset.left : offset.right, y: isOriginTop ? offset.top : offset.bottom }); this._setRectSize( stamp, rect ); // save its space in the packer this.shiftPacker.placed( rect ); }, this ); // reset shiftTargets var isHorizontal = this._getOption('horizontal'); var segmentName = isHorizontal ? 'rowHeight' : 'columnWidth'; var measure = isHorizontal ? 'height' : 'width'; this.shiftTargetKeys = []; this.shiftTargets = []; var boundsSize; var segment = this[ segmentName ]; segment = segment && segment + this.gutter; if ( segment ) { var segmentSpan = Math.ceil( dropItem.rect[ measure ] / segment ); var segs = Math.floor( ( this.shiftPacker[ measure ] + this.gutter ) / segment ); boundsSize = ( segs - segmentSpan ) * segment; // add targets on top for ( var i=0; i < segs; i++ ) { var initialX = isHorizontal ? 0 : i * segment; var initialY = isHorizontal ? i * segment : 0; this._addShiftTarget( initialX, initialY, boundsSize ); } } else { boundsSize = ( this.shiftPacker[ measure ] + this.gutter ) - dropItem.rect[ measure ]; this._addShiftTarget( 0, 0, boundsSize ); } // pack each item to measure where shiftTargets are var items = this._getItemsForLayout( this.items ); var packMethod = this._getPackMethod(); items.forEach( function( item ) { var rect = item.rect; this._setRectSize( item.element, rect ); this.shiftPacker[ packMethod ]( rect ); // add top left corner this._addShiftTarget( rect.x, rect.y, boundsSize ); // add bottom left / top right corner var cornerX = isHorizontal ? rect.x + rect.width : rect.x; var cornerY = isHorizontal ? rect.y : rect.y + rect.height; this._addShiftTarget( cornerX, cornerY, boundsSize ); if ( segment ) { // add targets for each column on bottom / row on right var segSpan = Math.round( rect[ measure ] / segment ); for ( var i=1; i < segSpan; i++ ) { var segX = isHorizontal ? cornerX : rect.x + segment * i; var segY = isHorizontal ? rect.y + segment * i : cornerY; this._addShiftTarget( segX, segY, boundsSize ); } } }, this ); }; proto._addShiftTarget = function( x, y, boundsSize ) { var checkCoord = this._getOption('horizontal') ? y : x; if ( checkCoord !== 0 && checkCoord > boundsSize ) { return; } // create string for a key, easier to keep track of what targets var key = x + ',' + y; var hasKey = this.shiftTargetKeys.indexOf( key ) != -1; if ( hasKey ) { return; } this.shiftTargetKeys.push( key ); this.shiftTargets.push({ x: x, y: y }); }; // -------------------------- drop -------------------------- // proto.shift = function( item, x, y ) { var shiftPosition; var minDistance = Infinity; var position = { x: x, y: y }; this.shiftTargets.forEach( function( target ) { var distance = getDistance( target, position ); if ( distance < minDistance ) { shiftPosition = target; minDistance = distance; } }); item.rect.x = shiftPosition.x; item.rect.y = shiftPosition.y; }; function getDistance( a, b ) { var dx = b.x - a.x; var dy = b.y - a.y; return Math.sqrt( dx * dx + dy * dy ); } // -------------------------- drag move -------------------------- // var DRAG_THROTTLE_TIME = 120; /** * handle an item drag move event * @param {Element} elem * @param {Number} x - horizontal change in position * @param {Number} y - vertical change in position */ proto.itemDragMove = function( elem, x, y ) { var item = this.isEnabled && this.getItem( elem ); if ( !item ) { return; } x -= this.size.paddingLeft; y -= this.size.paddingTop; var _this = this; function onDrag() { _this.shift( item, x, y ); item.positionDropPlaceholder(); _this.layout(); } // throttle var now = new Date(); if ( this._itemDragTime && now - this._itemDragTime < DRAG_THROTTLE_TIME ) { clearTimeout( this.dragTimeout ); this.dragTimeout = setTimeout( onDrag, DRAG_THROTTLE_TIME ); } else { onDrag(); this._itemDragTime = now; } }; // -------------------------- drag end -------------------------- // /** * handle an item drag end event * @param {Element} elem */ proto.itemDragEnd = function( elem ) { var item = this.isEnabled && this.getItem( elem ); if ( !item ) { return; } clearTimeout( this.dragTimeout ); item.element.classList.add('is-positioning-post-drag'); var completeCount = 0; var _this = this; function onDragEndLayoutComplete() { completeCount++; if ( completeCount != 2 ) { return; } // reset drag item item.element.classList.remove('is-positioning-post-drag'); item.hideDropPlaceholder(); _this.dispatchEvent( 'dragItemPositioned', null, [ item ] ); } item.once( 'layout', onDragEndLayoutComplete ); this.once( 'layoutComplete', onDragEndLayoutComplete ); item.moveTo( item.rect.x, item.rect.y ); this.layout(); this.dragItemCount = Math.max( 0, this.dragItemCount - 1 ); this.sortItemsByPosition(); item.disablePlacing(); this.unstamp( item.element ); }; /** * binds Draggabilly events * @param {Draggabilly} draggie */ proto.bindDraggabillyEvents = function( draggie ) { this._bindDraggabillyEvents( draggie, 'on' ); }; proto.unbindDraggabillyEvents = function( draggie ) { this._bindDraggabillyEvents( draggie, 'off' ); }; proto._bindDraggabillyEvents = function( draggie, method ) { var handlers = this.handleDraggabilly; draggie[ method ]( 'dragStart', handlers.dragStart ); draggie[ method ]( 'dragMove', handlers.dragMove ); draggie[ method ]( 'dragEnd', handlers.dragEnd ); }; /** * binds jQuery UI Draggable events * @param {jQuery} $elems */ proto.bindUIDraggableEvents = function( $elems ) { this._bindUIDraggableEvents( $elems, 'on' ); }; proto.unbindUIDraggableEvents = function( $elems ) { this._bindUIDraggableEvents( $elems, 'off' ); }; proto._bindUIDraggableEvents = function( $elems, method ) { var handlers = this.handleUIDraggable; $elems [ method ]( 'dragstart', handlers.start ) [ method ]( 'drag', handlers.drag ) [ method ]( 'dragstop', handlers.stop ); }; // ----- destroy ----- // var _destroy = proto.destroy; proto.destroy = function() { _destroy.apply( this, arguments ); // disable flag; prevent drag events from triggering. #72 this.isEnabled = false; }; // ----- ----- // Packery.Rect = Rect; Packery.Packer = Packer; return Packery; })); // source --> https://www.saiseva.org/wp-content/plugins/photoblocks-grid-gallery/public/js/photoblocks.public.js?ver=1.2.2 /*global jQuery*/ var PhotoBlocks = {}; //credits James Padolsey http://james.padolsey.com/ var qualifyURL = function (url) { var img = document.createElement("img"); img.src = url; // set string url url = img.src; // get qualified url img.src = null; // no server request return url; }; (function($) { $.fn.visible = function (partial) { if (!$(this).offset()) return true; var $t = $(this), $w = $(window), viewTop = $w.scrollTop(), viewBottom = viewTop + $w.height(), _top = $t.offset().top, _bottom = _top + $t.height(), compareTop = partial === true ? _bottom : _top, compareBottom = partial === true ? _top : _bottom; return ((compareBottom <= viewBottom) && (compareTop >= viewTop)); }; PhotoBlocks = function(conf) { this.$grid = null; this.$blocks = []; this.geometry = { width: 0, squareSize: 0, on: { before: null, after: null, refresh: null }, debug: false }; this.loaded_images = 0; this.err_images = 0; this.images_count = 0; this.mode = "grid"; this.packery_init = false; this.settings = { selector: null, columns: 4, padding: 10, disable_below: 320, image_quality: 80, imageExtraWidth: 0, imageFactor: 1.5, lazy: false, mobile_layout: [] }; for (var a in conf) { this.settings[a] = conf[a]; } this.effects = { fade: { animeOpts: { targets : ".pb-block", duration: function(t,i) { return 600 + i*75; }, easing: 'easeOutExpo', delay: function(t,i) { return i*50; }, opacity: { value: [0,1], easing: 'linear' }, } } }; /* Premium Code Stripped by Freemius */ if (this.init()) { this.load_images(this.$blocks); this.setup_social(); /* Premium Code Stripped by Freemius */ } }; PhotoBlocks.prototype.setup_social = function () { var self = this; function block_text($block) { var text = { title: "", description: "" }; if($block.find(".pb-title").length) text.title = $block.find(".pb-title").text(); if($block.find(".pb-description").length) text.description = $block.find(".pb-description").text(); return text; } self.social_actions = { facebook: function ($block) { var text = block_text($block); var url = "https://www.facebook.com/dialog/feed?app_id=1447224948871585&"+ "link="+encodeURIComponent(location.href)+"&" + "display=popup&"+ "name="+encodeURIComponent(text.title)+"&"+ "caption=&"+ "description="+encodeURIComponent(text.description)+"&"+ "ref=share&"+ "actions={%22name%22:%22View%20the%20gallery%22,%20%22link%22:%22"+encodeURIComponent(location.href)+"%22}&"+ "redirect_uri=http://www.final-tiles-gallery.com/facebook_redirect.html"; var w = window.open(url, "photoblocks-share-facebook", "location=1,status=1,scrollbars=1,width=600,height=400"); w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); }, twitter: function ($block) { var text = block_text($block); var w = window.open("https://twitter.com/intent/tweet?url=" + encodeURI(location.href.split('#')[0]) + "&text=" + encodeURI(text.title + " " + text.description), "photoblocks-share-twitter", "location=1,status=1,scrollbars=1,width=600,height=400"); w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); }, houzz: function ($block) { var image = $block.find(".pb-image").attr("src"); var text = block_text($block); var w = window.open("http://www.houzz.com/imageClipperUpload?imageUrl="+encodeURIComponent(qualifyURL(image))+"&title="+ text.title + " " + text.description +"&link=" + encodeURI(location.href), "photoblocks-share-houzz", "location=1,status=1,scrollbars=1,width=800,height=500"); w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); }, pinterest: function ($block) { var image = $block.find(".pb-image").attr("src"); var text = block_text($block); var url = "http://pinterest.com/pin/create/button/?url=" + encodeURIComponent(location.href) + "&description=" + encodeURI(text.title + " " + text.description); url += ("&media=" + encodeURIComponent(qualifyURL(image))); var w = window.open(url, "photoblocks-share-pinterest", "location=1,status=1,scrollbars=1,width=600,height=400"); w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); }, google: function ($block) { var url = "https://plus.google.com/share?url=" + encodeURI(location.href); var w = window.open(url, "photoblocks-share-google", "location=1,status=1,scrollbars=1,width=600,height=400"); w.moveTo((screen.width / 2) - (300), (screen.height / 2) - (200)); } }; this.$blocks.each(function (i, block) { var $block = $(block); $block.find(".pb-social button").each(function (i, button) { var $button = $(button); var social = $button.data("social"); $button.click(function (e) { e.preventDefault(); e.stopPropagation(); self.social_actions[social]($block); }); }); }); }; PhotoBlocks.prototype.apply_effects = function ($block) { var anim = this.$grid.data("anim"); var effect = this.effects[anim]; effect.animeOpts.targets = $block.get(0); $block.css({ transition: "none" }); anime(effect.animeOpts); setTimeout(function () { $block.css({ transition: "left .25s, top .45s, transform .25s" }); }, 1000); }; PhotoBlocks.prototype.print_i = function(data) { if (this.settings.debug) console.info("PB > ", data); }; PhotoBlocks.prototype.print_e = function(data) { if (this.settings.debug) console.error("PB > ", data); }; PhotoBlocks.prototype.print_w = function(data) { if (this.settings.debug) console.warn("PB > ", data); }; /* Premium Code Stripped by Freemius */ PhotoBlocks.prototype.cellSize = function() { var self = this; var w = self.$grid.width(); if(w < self.settings.disable_below) { self.$grid.addClass("pb-disabled"); this.mode.type = "stack"; } else { self.$grid.removeClass("pb-disabled"); this.mode.type = "grid"; } if(this.mode == "stack") return this.geometry.width; var w = this.geometry.width - this.settings.padding * (this.settings.columns - 1); var size = (w / this.settings.columns); return size; }; PhotoBlocks.prototype.init_packery = function() { var self = this; self.build(); if(self.$grid.find(".pb-blocks").data('packery')) self.$grid.find(".pb-blocks").packery('destroy'); self.$grid.find(".pb-blocks").css({ width: "calc(100% + " + self.settings.padding + "px)" }); var settings = { itemSelector: '.pb-block', gutter: self.settings.padding, resize: false }; if(this.mode.type != "stack") { settings.columnWidth = self.geometry.squareSize; settings.rowHeight = self.geometry.squareSize; self.$grid.find(".pb-blocks").packery(settings); } this.packery_init = true; } PhotoBlocks.prototype.loaded_image = function () { var self = this; if(self.err_images == self.images_count) { self.$grid.append("Cannot load all images, check cache settings"); } }; PhotoBlocks.prototype.apply_alignments = function($image, img) { var $block = $image.parent(); var bw = $block.width(); var bh = $block.height(); var iw = $image.width(); var ih = $image.height(); if(ih > bh) { switch($block.data("valign")) { case "top": $image.css({ top: 0, bottom: "auto" }); break; case "bottom": $image.css({ top: "auto", bottom: 0 }); break; case "center": $image.css({ top: - ((ih - bh) / 2), bottom: "auto" }); break; } } if(iw > bw) { switch($block.data("halign")) { case "left": $image.css({ left: 0, right: "auto" }); break; case "right": $image.css({ left: "auto", right: 0 }); break; case "center": $image.css({ left: - ((iw - bw) / 2), right: "auto" }); break; } } } PhotoBlocks.prototype.load_images = function($blocks) { var self = this; $blocks.not(".pb-ready").each(function() { var $block = $(this); if(self.settings.lazy && ! $block.visible(true)) return false; var type = $(this).data("type"); if(type == "empty" || type == "text") { $block.addClass("pb-ready"); self.apply_effects($block); } if(type == "image" || type == "post") { self.setImageSrc($block) var $image = $(this).find(".pb-image"); var src = $image.attr("src"); var i = new Image(); i.onload = function () { self.loaded_images++; self.loaded_image(); $block.addClass("pb-ready"); $block.data("image-width", i.width); $block.data("image-height", i.height); //console.log(i.src, $block.data("image-width"), $block.data("image-height")); if(! self.settings.resizer) self.apply_alignments($image, i); self.apply_effects($block); }; i.onerror = function () { self.err_images++; $block.addClass("pb-ready-err"); console.warn("Loading error", $block); }; i.src = src; } }); }; PhotoBlocks.prototype.setImageSrc = function($block) { var self = this; if($block.data("type") == "image" || $block.data("type") == "post") { var valign = $block.data("valign"); var halign = $block.data("halign"); var rowspan = $block.data("rowspan"); var colspan = $block.data("colspan"); var src = $block.find(".pb-image").data("pb-source"); var width = self.getSnappedSize( colspan * self.geometry.squareSize ); var height = self.getSnappedSize( rowspan * self.geometry.squareSize ); width *= self.settings.imageFactor; height *= self.settings.imageFactor; if(self.mode.type == "stack") { width = self.geometry.width; height = null; } var resized_src = self.getImageUrl( src, width, height, valign, halign, self.settings.imageExtraWidth ); $block.find(".pb-image").attr("src", resized_src).show(); } } PhotoBlocks.prototype.currentMode = function() { var self = this; var w = $(window).width(); var mode = { type: "grid" }; if(w < self.settings.disable_below) return { type: "stack" }; /* Premium Code Stripped by Freemius */ return mode; } PhotoBlocks.prototype.build = function() { var self = this; var w = self.$grid.width(); this.mode = self.currentMode(); if(this.mode.type == "stack") { self.$grid.addClass("pb-disabled"); } else { self.$grid.removeClass("pb-disabled"); } this.print_i("Gallery mode: " + this.mode.type); this.$blocks.not(".pb-filtered").each(function() { var $block = $(this); var rowspan = $block.data("rowspan"); var colspan = $block.data("colspan"); var width = self.getSnappedSize( colspan * self.geometry.squareSize ); var height = self.getSnappedSize( rowspan * self.geometry.squareSize ); //self.print_i("Calculated: " + width + "x" + height); if(self.mode.type == "stack") { width = "100%"; height = "auto"; console.log("!"); $block.css({ position: "relative", marginBottom: self.settings.padding }).find(".pb-image").css({ position: "static", width: "100%", height: "auto", position: "static" }); } else if(self.mode.type == "grid") { } else if(self.mode.type == "mobile") { width = (w - ( (self.mode.layout.cols - 1) * self.settings.padding)) / self.mode.layout.cols; height = width; /*if(self.mode.layout.square) { height = width; } else { height = w / width * height; }*/ self.geometry.squareSize = width } self.print_i("build: " + (width + "x" + height)); $block.css({ width: width, height: height }); if(! self.settings.lazy) self.setImageSrc($block) }); }; PhotoBlocks.prototype.getImageUrl = function( src, width, height, valign, halign, exceeding_w ) { if(! this.settings.resizer) return src; var parts = []; var v = "c"; if (valign == "top") v = "t"; if (valign == "bottom") v = "b"; var h = halign.substr(0, 1); //var w_ = colspan * 200 + exceeding_w; //var h_ = rowspan * 200; var w_ = width + exceeding_w; var h_ = height; parts.push("q=" + this.settings.image_quality); parts.push("src=" + src); parts.push("w=" + w_); if(h_) parts.push("h=" + h_); parts.push("a=" + v + h); parts.push("zc=4"); return this.settings.resizer + "?" + parts.join("&"); }; PhotoBlocks.prototype.getSquareIndex = function(len) { return Math.round(len / this.geometry.squareSize); }; PhotoBlocks.prototype.getSnappedSize = function(len) { var x = this.getSquareIndex(len); return this.geometry.squareSize * x + this.settings.padding * (x - 1); }; PhotoBlocks.prototype.init = function() { if(this.settings.on.before) this.settings.on.before(); if (!this.settings.selector) { this.print_e("Null selector !"); return false; } this.settings.imageFactor = parseFloat(this.settings.imageFactor); if(this.settings.imageFactor == 0 || isNaN(this.settings.imageFactor)) this.settings.imageFactor = 1.5; this.$grid = $(this.settings.selector); if (this.$grid.length == 0) { this.print_e("Gallery element not found!"); return; } this.$blocks = this.$grid.find(".pb-block"); if (this.$blocks.length == 0) { this.print_w("Useless empty gallery?"); } this.images_count = this.$blocks.find(".pb-image").length; this.$blocks.each(function () { var $block = $(this); $block.data("conf", { geometry: { colspan: $block.data("colspan"), rowspan: $block.data("rowspan"), col: $block.data("col"), row: $block.data("row") } }); $block.data("previous_conf", $.extend({}, $block.data("conf"))); }); //TODO if width is 0 delay and loop until width is gt 0 this.geometry.width = this.$grid.width(); this.geometry.squareSize = this.cellSize(); this.print_i("width: " + this.geometry.width); this.print_i("squareSize: " + this.geometry.squareSize); var self = this; //self.build(); if(location.hash.substr(0, 5) != "#pbf-" || location.hash == "#pbf-all") self.init_packery(); $(window).resize(function() { self.resizeTO = setTimeout(function() { self.print_i("resizing gallery"); var w = self.$grid.width(); self.print_i("new gallery width: " + w); if (w != self.geometry.width) { clearInterval(self.resizeTO); self.print_i("gallery width changed, resizing"); self.geometry.width = w; self.geometry.squareSize = self.cellSize(); self.init_packery(); if(self.settings.on.refresh) self.settings.on.refresh(); } }, 500); }); if(! self.settings.lazy) { self.load_images(self.$blocks); } /* Premium Code Stripped by Freemius */ if(this.settings.on.after) this.settings.on.after(); return true; }; })(jQuery); // source --> https://www.saiseva.org/wp-content/plugins/testimonial-rotator/js/jquery.cycletwo.js?ver=5.6.2 /*! * jQuery cycletwo; build: v20131005 * http://jquery.malsup.com/cycletwo/ * Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL */ /*! core engine; version: 20131003 */ ;(function($) { "use strict"; var version = '20131003'; $.fn.cycletwo = function( options ) { // fix mistakes with the ready state var o; if ( this.length === 0 && !$.isReady ) { o = { s: this.selector, c: this.context }; $.fn.cycletwo.log('requeuing slideshow (dom not ready)'); $(function() { $( o.s, o.c ).cycletwo(options); }); return this; } return this.each(function() { var data, opts, shortName, val; var container = $(this); var log = $.fn.cycletwo.log; if ( container.data('cycletwo.opts') ) return; // already initialized if ( container.data('cycletwo-log') === false || ( options && options.log === false ) || ( opts && opts.log === false) ) { log = $.noop; } log('--c2 init--'); data = container.data(); for (var p in data) { // allow props to be accessed sans 'cycletwo' prefix and log the overrides if (data.hasOwnProperty(p) && /^cycletwo[A-Z]+/.test(p) ) { val = data[p]; shortName = p.match(/^cycletwo(.*)/)[1].replace(/^[A-Z]/, lowerCase); log(shortName+':', val, '('+typeof val +')'); data[shortName] = val; } } opts = $.extend( {}, $.fn.cycletwo.defaults, data, options || {}); opts.timeoutId = 0; opts.paused = opts.paused || false; // #57 opts.container = container; opts._maxZ = opts.maxZ; opts.API = $.extend ( { _container: container }, $.fn.cycletwo.API ); opts.API.log = log; opts.API.trigger = function( eventName, args ) { opts.container.trigger( eventName, args ); return opts.API; }; container.data( 'cycletwo.opts', opts ); container.data( 'cycletwo.API', opts.API ); // opportunity for plugins to modify opts and API opts.API.trigger('cycletwo-bootstrap', [ opts, opts.API ]); opts.API.addInitialSlides(); opts.API.preInitSlideshow(); if ( opts.slides.length ) opts.API.initSlideshow(); }); }; $.fn.cycletwo.API = { opts: function() { return this._container.data( 'cycletwo.opts' ); }, addInitialSlides: function() { var opts = this.opts(); var slides = opts.slides; opts.slideCount = 0; opts.slides = $(); // empty set // add slides that already exist slides = slides.jquery ? slides : opts.container.find( slides ); if ( opts.random ) { slides.sort(function() {return Math.random() - 0.5;}); } opts.API.add( slides ); }, preInitSlideshow: function() { var opts = this.opts(); opts.API.trigger('cycletwo-pre-initialize', [ opts ]); var tx = $.fn.cycletwo.transitions[opts.fx]; if (tx && $.isFunction(tx.preInit)) tx.preInit( opts ); opts._preInitialized = true; }, postInitSlideshow: function() { var opts = this.opts(); opts.API.trigger('cycletwo-post-initialize', [ opts ]); var tx = $.fn.cycletwo.transitions[opts.fx]; if (tx && $.isFunction(tx.postInit)) tx.postInit( opts ); }, initSlideshow: function() { var opts = this.opts(); var pauseObj = opts.container; var slideOpts; opts.API.calcFirstSlide(); if ( opts.container.css('position') == 'static' ) opts.container.css('position', 'relative'); $(opts.slides[opts.currSlide]).css('opacity',1).show(); opts.API.stackSlides( opts.slides[opts.currSlide], opts.slides[opts.nextSlide], !opts.reverse ); if ( opts.pauseOnHover ) { // allow pauseOnHover to specify an element if ( opts.pauseOnHover !== true ) pauseObj = $( opts.pauseOnHover ); pauseObj.hover( function(){ opts.API.pause( true ); }, function(){ opts.API.resume( true ); } ); } // stage initial transition if ( opts.timeout ) { slideOpts = opts.API.getSlideOpts( opts.currSlide ); opts.API.queueTransition( slideOpts, slideOpts.timeout + opts.delay ); } opts._initialized = true; opts.API.updateView( true ); opts.API.trigger('cycletwo-initialized', [ opts ]); opts.API.postInitSlideshow(); }, pause: function( hover ) { var opts = this.opts(), slideOpts = opts.API.getSlideOpts(), alreadyPaused = opts.hoverPaused || opts.paused; if ( hover ) opts.hoverPaused = true; else opts.paused = true; if ( ! alreadyPaused ) { opts.container.addClass('cycletwo-paused'); opts.API.trigger('cycletwo-paused', [ opts ]).log('cycletwo-paused'); if ( slideOpts.timeout ) { clearTimeout( opts.timeoutId ); opts.timeoutId = 0; // determine how much time is left for the current slide opts._remainingTimeout -= ( $.now() - opts._lastQueue ); if ( opts._remainingTimeout < 0 || isNaN(opts._remainingTimeout) ) opts._remainingTimeout = undefined; } } }, resume: function( hover ) { var opts = this.opts(), alreadyResumed = !opts.hoverPaused && !opts.paused, remaining; if ( hover ) opts.hoverPaused = false; else opts.paused = false; if ( ! alreadyResumed ) { opts.container.removeClass('cycletwo-paused'); // #gh-230; if an animation is in progress then don't queue a new transition; it will // happen naturally if ( opts.slides.filter(':animated').length === 0 ) opts.API.queueTransition( opts.API.getSlideOpts(), opts._remainingTimeout ); opts.API.trigger('cycletwo-resumed', [ opts, opts._remainingTimeout ] ).log('cycletwo-resumed'); } }, add: function( slides, prepend ) { var opts = this.opts(); var oldSlideCount = opts.slideCount; var startSlideshow = false; var len; if ( $.type(slides) == 'string') slides = $.trim( slides ); $( slides ).each(function(i) { var slideOpts; var slide = $(this); if ( prepend ) opts.container.prepend( slide ); else opts.container.append( slide ); opts.slideCount++; slideOpts = opts.API.buildSlideOpts( slide ); if ( prepend ) opts.slides = $( slide ).add( opts.slides ); else opts.slides = opts.slides.add( slide ); opts.API.initSlide( slideOpts, slide, --opts._maxZ ); slide.data('cycletwo.opts', slideOpts); opts.API.trigger('cycletwo-slide-added', [ opts, slideOpts, slide ]); }); opts.API.updateView( true ); startSlideshow = opts._preInitialized && (oldSlideCount < 2 && opts.slideCount >= 1); if ( startSlideshow ) { if ( !opts._initialized ) opts.API.initSlideshow(); else if ( opts.timeout ) { len = opts.slides.length; opts.nextSlide = opts.reverse ? len - 1 : 1; if ( !opts.timeoutId ) { opts.API.queueTransition( opts ); } } } }, calcFirstSlide: function() { var opts = this.opts(); var firstSlideIndex; firstSlideIndex = parseInt( opts.startingSlide || 0, 10 ); if (firstSlideIndex >= opts.slides.length || firstSlideIndex < 0) firstSlideIndex = 0; opts.currSlide = firstSlideIndex; if ( opts.reverse ) { opts.nextSlide = firstSlideIndex - 1; if (opts.nextSlide < 0) opts.nextSlide = opts.slides.length - 1; } else { opts.nextSlide = firstSlideIndex + 1; if (opts.nextSlide == opts.slides.length) opts.nextSlide = 0; } }, calcNextSlide: function() { var opts = this.opts(); var roll; if ( opts.reverse ) { roll = (opts.nextSlide - 1) < 0; opts.nextSlide = roll ? opts.slideCount - 1 : opts.nextSlide-1; opts.currSlide = roll ? 0 : opts.nextSlide+1; } else { roll = (opts.nextSlide + 1) == opts.slides.length; opts.nextSlide = roll ? 0 : opts.nextSlide+1; opts.currSlide = roll ? opts.slides.length-1 : opts.nextSlide-1; } }, calcTx: function( slideOpts, manual ) { var opts = slideOpts; var tx; if ( manual && opts.manualFx ) tx = $.fn.cycletwo.transitions[opts.manualFx]; if ( !tx ) tx = $.fn.cycletwo.transitions[opts.fx]; if (!tx) { tx = $.fn.cycletwo.transitions.fade; opts.API.log('Transition "' + opts.fx + '" not found. Using fade.'); } return tx; }, prepareTx: function( manual, fwd ) { var opts = this.opts(); var after, curr, next, slideOpts, tx; if ( opts.slideCount < 2 ) { opts.timeoutId = 0; return; } if ( manual && ( !opts.busy || opts.manualTrump ) ) { opts.API.stopTransition(); opts.busy = false; clearTimeout(opts.timeoutId); opts.timeoutId = 0; } if ( opts.busy ) return; if ( opts.timeoutId === 0 && !manual ) return; curr = opts.slides[opts.currSlide]; next = opts.slides[opts.nextSlide]; slideOpts = opts.API.getSlideOpts( opts.nextSlide ); tx = opts.API.calcTx( slideOpts, manual ); opts._tx = tx; if ( manual && slideOpts.manualSpeed !== undefined ) slideOpts.speed = slideOpts.manualSpeed; // if ( opts.nextSlide === opts.currSlide ) // opts.API.calcNextSlide(); // ensure that: // 1. advancing to a different slide // 2. this is either a manual event (prev/next, pager, cmd) or // a timer event and slideshow is not paused if ( opts.nextSlide != opts.currSlide && (manual || (!opts.paused && !opts.hoverPaused && opts.timeout) )) { // #62 opts.API.trigger('cycletwo-before', [ slideOpts, curr, next, fwd ]); if ( tx.before ) tx.before( slideOpts, curr, next, fwd ); after = function() { opts.busy = false; // #76; bail if slideshow has been destroyed if (! opts.container.data( 'cycletwo.opts' ) ) return; if (tx.after) tx.after( slideOpts, curr, next, fwd ); opts.API.trigger('cycletwo-after', [ slideOpts, curr, next, fwd ]); opts.API.queueTransition( slideOpts); opts.API.updateView( true ); }; opts.busy = true; if (tx.transition) tx.transition(slideOpts, curr, next, fwd, after); else opts.API.doTransition( slideOpts, curr, next, fwd, after); opts.API.calcNextSlide(); opts.API.updateView(); } else { opts.API.queueTransition( slideOpts ); } }, // perform the actual animation doTransition: function( slideOpts, currEl, nextEl, fwd, callback) { var opts = slideOpts; var curr = $(currEl), next = $(nextEl); var fn = function() { // make sure animIn has something so that callback doesn't trigger immediately next.animate(opts.animIn || { opacity: 1}, opts.speed, opts.easeIn || opts.easing, callback); }; next.css(opts.cssBefore || {}); curr.animate(opts.animOut || {}, opts.speed, opts.easeOut || opts.easing, function() { curr.css(opts.cssAfter || {}); if (!opts.sync) { fn(); } }); if (opts.sync) { fn(); } }, queueTransition: function( slideOpts, specificTimeout ) { var opts = this.opts(); var timeout = specificTimeout !== undefined ? specificTimeout : slideOpts.timeout; if (opts.nextSlide === 0 && --opts.loop === 0) { opts.API.log('terminating; loop=0'); opts.timeout = 0; if ( timeout ) { setTimeout(function() { opts.API.trigger('cycletwo-finished', [ opts ]); }, timeout); } else { opts.API.trigger('cycletwo-finished', [ opts ]); } // reset nextSlide opts.nextSlide = opts.currSlide; return; } if ( timeout ) { opts._lastQueue = $.now(); if ( specificTimeout === undefined ) opts._remainingTimeout = slideOpts.timeout; if ( !opts.paused && ! opts.hoverPaused ) { opts.timeoutId = setTimeout(function() { opts.API.prepareTx( false, !opts.reverse ); }, timeout ); } } }, stopTransition: function() { var opts = this.opts(); if ( opts.slides.filter(':animated').length ) { opts.slides.stop(false, true); opts.API.trigger('cycletwo-transition-stopped', [ opts ]); } if ( opts._tx && opts._tx.stopTransition ) opts._tx.stopTransition( opts ); }, // advance slide forward or back advanceSlide: function( val ) { var opts = this.opts(); clearTimeout(opts.timeoutId); opts.timeoutId = 0; opts.nextSlide = opts.currSlide + val; if (opts.nextSlide < 0) opts.nextSlide = opts.slides.length - 1; else if (opts.nextSlide >= opts.slides.length) opts.nextSlide = 0; opts.API.prepareTx( true, val >= 0 ); return false; }, buildSlideOpts: function( slide ) { var opts = this.opts(); var val, shortName; var slideOpts = slide.data() || {}; for (var p in slideOpts) { // allow props to be accessed sans 'cycletwo' prefix and log the overrides if (slideOpts.hasOwnProperty(p) && /^cycletwo[A-Z]+/.test(p) ) { val = slideOpts[p]; shortName = p.match(/^cycletwo(.*)/)[1].replace(/^[A-Z]/, lowerCase); opts.API.log('['+(opts.slideCount-1)+']', shortName+':', val, '('+typeof val +')'); slideOpts[shortName] = val; } } slideOpts = $.extend( {}, $.fn.cycletwo.defaults, opts, slideOpts ); slideOpts.slideNum = opts.slideCount; try { // these props should always be read from the master state object delete slideOpts.API; delete slideOpts.slideCount; delete slideOpts.currSlide; delete slideOpts.nextSlide; delete slideOpts.slides; } catch(e) { // no op } return slideOpts; }, getSlideOpts: function( index ) { var opts = this.opts(); if ( index === undefined ) index = opts.currSlide; var slide = opts.slides[index]; var slideOpts = $(slide).data('cycletwo.opts'); return $.extend( {}, opts, slideOpts ); }, initSlide: function( slideOpts, slide, suggestedZindex ) { var opts = this.opts(); slide.css( slideOpts.slideCss || {} ); if ( suggestedZindex > 0 ) slide.css( 'zIndex', suggestedZindex ); // ensure that speed settings are sane if ( isNaN( slideOpts.speed ) ) slideOpts.speed = $.fx.speeds[slideOpts.speed] || $.fx.speeds._default; if ( !slideOpts.sync ) slideOpts.speed = slideOpts.speed / 2; slide.addClass( opts.slideClass ); }, updateView: function( isAfter, isDuring ) { var opts = this.opts(); if ( !opts._initialized ) return; var slideOpts = opts.API.getSlideOpts(); var currSlide = opts.slides[ opts.currSlide ]; if ( ! isAfter && isDuring !== true ) { opts.API.trigger('cycletwo-update-view-before', [ opts, slideOpts, currSlide ]); if ( opts.updateView < 0 ) return; } if ( opts.slideActiveClass ) { opts.slides.removeClass( opts.slideActiveClass ) .eq( opts.currSlide ).addClass( opts.slideActiveClass ); } if ( isAfter && opts.hideNonActive ) opts.slides.filter( ':not(.' + opts.slideActiveClass + ')' ).hide(); opts.API.trigger('cycletwo-update-view', [ opts, slideOpts, currSlide, isAfter ]); if ( isAfter ) opts.API.trigger('cycletwo-update-view-after', [ opts, slideOpts, currSlide ]); }, getComponent: function( name ) { var opts = this.opts(); var selector = opts[name]; if (typeof selector === 'string') { // if selector is a child, sibling combinator, adjancent selector then use find, otherwise query full dom return (/^\s*[\>|\+|~]/).test( selector ) ? opts.container.find( selector ) : $( selector ); } if (selector.jquery) return selector; return $(selector); }, stackSlides: function( curr, next, fwd ) { var opts = this.opts(); if ( !curr ) { curr = opts.slides[opts.currSlide]; next = opts.slides[opts.nextSlide]; fwd = !opts.reverse; } // reset the zIndex for the common case: // curr slide on top, next slide beneath, and the rest in order to be shown $(curr).css('zIndex', opts.maxZ); var i; var z = opts.maxZ - 2; var len = opts.slideCount; if (fwd) { for ( i = opts.currSlide + 1; i < len; i++ ) $( opts.slides[i] ).css( 'zIndex', z-- ); for ( i = 0; i < opts.currSlide; i++ ) $( opts.slides[i] ).css( 'zIndex', z-- ); } else { for ( i = opts.currSlide - 1; i >= 0; i-- ) $( opts.slides[i] ).css( 'zIndex', z-- ); for ( i = len - 1; i > opts.currSlide; i-- ) $( opts.slides[i] ).css( 'zIndex', z-- ); } $(next).css('zIndex', opts.maxZ - 1); }, getSlideIndex: function( el ) { return this.opts().slides.index( el ); } }; // API // default logger $.fn.cycletwo.log = function log() { /*global console:true */ if (window.console && console.log) console.log('[cycletwo] ' + Array.prototype.join.call(arguments, ' ') ); }; $.fn.cycletwo.version = function() { return 'cycletwo: ' + version; }; // helper functions function lowerCase(s) { return (s || '').toLowerCase(); } // expose transition object $.fn.cycletwo.transitions = { custom: { }, none: { before: function( opts, curr, next, fwd ) { opts.API.stackSlides( next, curr, fwd ); opts.cssBefore = { opacity: 1, display: 'block' }; } }, fade: { before: function( opts, curr, next, fwd ) { var css = opts.API.getSlideOpts( opts.nextSlide ).slideCss || {}; opts.API.stackSlides( curr, next, fwd ); opts.cssBefore = $.extend(css, { opacity: 0, display: 'block' }); opts.animIn = { opacity: 1 }; opts.animOut = { opacity: 0 }; } }, fadeout: { before: function( opts , curr, next, fwd ) { var css = opts.API.getSlideOpts( opts.nextSlide ).slideCss || {}; opts.API.stackSlides( curr, next, fwd ); opts.cssBefore = $.extend(css, { opacity: 1, display: 'block' }); opts.animOut = { opacity: 0 }; } }, scrollHorz: { before: function( opts, curr, next, fwd ) { opts.API.stackSlides( curr, next, fwd ); var w = opts.container.css('overflow','hidden').width(); opts.cssBefore = { left: fwd ? w : - w, top: 0, opacity: 1, display: 'block' }; opts.cssAfter = { zIndex: opts._maxZ - 2, left: 0 }; opts.animIn = { left: 0 }; opts.animOut = { left: fwd ? -w : w }; } } }; // @see: http://jquery.malsup.com/cycletwo/api $.fn.cycletwo.defaults = { allowWrap: true, autoSelector: '.cycletwo-slideshow[data-cycletwo-auto-init!=false]', delay: 0, easing: null, fx: 'fade', hideNonActive: true, loop: 0, manualFx: undefined, manualSpeed: undefined, manualTrump: true, maxZ: 100, pauseOnHover: false, reverse: false, slideActiveClass: 'cycletwo-slide-active', slideClass: 'cycletwo-slide', slideCss: { position: 'absolute', top: 0, left: 0 }, slides: '> img', speed: 500, startingSlide: 0, sync: true, timeout: 4000, updateView: -1 }; // automatically find and run slideshows $(document).ready(function() { $( $.fn.cycletwo.defaults.autoSelector ).cycletwo(); }); })(jQuery); /*! cycletwo autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { autoHeight: 0 // setting this option to false disables autoHeight logic }); $(document).on( 'cycletwo-initialized', function( e, opts ) { var autoHeight = opts.autoHeight; var t = $.type( autoHeight ); var resizeThrottle = null; var ratio; if ( t !== 'string' && t !== 'number' ) return; // bind events opts.container.on( 'cycletwo-slide-added cycletwo-slide-removed', initAutoHeight ); opts.container.on( 'cycletwo-destroyed', onDestroy ); if ( autoHeight == 'container' ) { opts.container.on( 'cycletwo-before', onBefore ); } else if ( t === 'string' && /\d+\:\d+/.test( autoHeight ) ) { // use ratio ratio = autoHeight.match(/(\d+)\:(\d+)/); ratio = ratio[1] / ratio[2]; opts._autoHeightRatio = ratio; } // if autoHeight is a number then we don't need to recalculate the sentinel // index on resize if ( t !== 'number' ) { // bind unique resize handler per slideshow (so it can be 'off-ed' in onDestroy) opts._autoHeightOnResize = function () { clearTimeout( resizeThrottle ); resizeThrottle = setTimeout( onResize, 50 ); }; $(window).on( 'resize orientationchange', opts._autoHeightOnResize ); } setTimeout( onResize, 30 ); function onResize() { initAutoHeight( e, opts ); } }); function initAutoHeight( e, opts ) { var clone, height, sentinelIndex; var autoHeight = opts.autoHeight; if ( autoHeight == 'container' ) { height = $( opts.slides[ opts.currSlide ] ).outerHeight(); opts.container.height( height ); } else if ( opts._autoHeightRatio ) { opts.container.height( opts.container.width() / opts._autoHeightRatio ); } else if ( autoHeight === 'calc' || ( $.type( autoHeight ) == 'number' && autoHeight >= 0 ) ) { if ( autoHeight === 'calc' ) sentinelIndex = calcSentinelIndex( e, opts ); else if ( autoHeight >= opts.slides.length ) sentinelIndex = 0; else sentinelIndex = autoHeight; // only recreate sentinel if index is different if ( sentinelIndex == opts._sentinelIndex ) return; opts._sentinelIndex = sentinelIndex; if ( opts._sentinel ) opts._sentinel.remove(); // clone existing slide as sentinel clone = $( opts.slides[ sentinelIndex ].cloneNode(true) ); // #50; remove special attributes from cloned content clone.removeAttr( 'id name rel' ).find( '[id],[name],[rel]' ).removeAttr( 'id name rel' ); clone.css({ position: 'static', visibility: 'hidden', display: 'block' }).prependTo( opts.container ).addClass('cycletwo-sentinel cycletwo-slide').removeClass('cycletwo-slide-active'); clone.find( '*' ).css( 'visibility', 'hidden' ); opts._sentinel = clone; } } function calcSentinelIndex( e, opts ) { var index = 0, max = -1; // calculate tallest slide index opts.slides.each(function(i) { var h = $(this).height(); if ( h > max ) { max = h; index = i; } }); return index; } function onBefore( e, opts, outgoing, incoming, forward ) { var h = $(incoming).outerHeight(); var duration = opts.sync ? opts.speed / 2 : opts.speed; opts.container.animate( { height: h }, duration ); } function onDestroy( e, opts ) { if ( opts._autoHeightOnResize ) { $(window).off( 'resize orientationchange', opts._autoHeightOnResize ); opts._autoHeightOnResize = null; } opts.container.off( 'cycletwo-slide-added cycletwo-slide-removed', initAutoHeight ); opts.container.off( 'cycletwo-destroyed', onDestroy ); opts.container.off( 'cycletwo-before', onBefore ); if ( opts._sentinel ) { opts._sentinel.remove(); opts._sentinel = null; } } })(jQuery); /*! caption plugin for cycletwo; version: 20130306 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { caption: '> .cycletwo-caption', captionTemplate: '{{slideNum}} / {{slideCount}}', overlay: '> .cycletwo-overlay', overlayTemplate: '
    {{title}}
    {{desc}}
    ', captionModule: 'caption' }); $(document).on( 'cycletwo-update-view', function( e, opts, slideOpts, currSlide ) { if ( opts.captionModule !== 'caption' ) return; var el; $.each(['caption','overlay'], function() { var name = this; var template = slideOpts[name+'Template']; var el = opts.API.getComponent( name ); if( el.length && template ) { el.html( opts.API.tmpl( template, slideOpts, opts, currSlide ) ); el.show(); } else { el.hide(); } }); }); $(document).on( 'cycletwo-destroyed', function( e, opts ) { var el; $.each(['caption','overlay'], function() { var name = this, template = opts[name+'Template']; if ( opts[name] && template ) { el = opts.API.getComponent( 'caption' ); el.empty(); } }); }); })(jQuery); /*! command plugin for cycletwo; version: 20130707 */ (function($) { "use strict"; var c2 = $.fn.cycletwo; $.fn.cycletwo = function( options ) { var cmd, cmdFn, opts; var args = $.makeArray( arguments ); if ( $.type( options ) == 'number' ) { return this.cycletwo( 'goto', options ); } if ( $.type( options ) == 'string' ) { return this.each(function() { var cmdArgs; cmd = options; opts = $(this).data('cycletwo.opts'); if ( opts === undefined ) { c2.log('slideshow must be initialized before sending commands; "' + cmd + '" ignored'); return; } else { cmd = cmd == 'goto' ? 'jump' : cmd; // issue #3; change 'goto' to 'jump' internally cmdFn = opts.API[ cmd ]; if ( $.isFunction( cmdFn )) { cmdArgs = $.makeArray( args ); cmdArgs.shift(); return cmdFn.apply( opts.API, cmdArgs ); } else { c2.log( 'unknown command: ', cmd ); } } }); } else { return c2.apply( this, arguments ); } }; // copy props $.extend( $.fn.cycletwo, c2 ); $.extend( c2.API, { next: function() { var opts = this.opts(); if ( opts.busy && ! opts.manualTrump ) return; var count = opts.reverse ? -1 : 1; if ( opts.allowWrap === false && ( opts.currSlide + count ) >= opts.slideCount ) return; opts.API.advanceSlide( count ); opts.API.trigger('cycletwo-next', [ opts ]).log('cycletwo-next'); }, prev: function() { var opts = this.opts(); if ( opts.busy && ! opts.manualTrump ) return; var count = opts.reverse ? 1 : -1; if ( opts.allowWrap === false && ( opts.currSlide + count ) < 0 ) return; opts.API.advanceSlide( count ); opts.API.trigger('cycletwo-prev', [ opts ]).log('cycletwo-prev'); }, destroy: function() { this.stop(); //#204 var opts = this.opts(); var clean = $.isFunction( $._data ) ? $._data : $.noop; // hack for #184 and #201 clearTimeout(opts.timeoutId); opts.timeoutId = 0; opts.API.stop(); opts.API.trigger( 'cycletwo-destroyed', [ opts ] ).log('cycletwo-destroyed'); opts.container.removeData(); clean( opts.container[0], 'parsedAttrs', false ); // #75; remove inline styles if ( ! opts.retainStylesOnDestroy ) { opts.container.removeAttr( 'style' ); opts.slides.removeAttr( 'style' ); opts.slides.removeClass( opts.slideActiveClass ); } opts.slides.each(function() { $(this).removeData(); clean( this, 'parsedAttrs', false ); }); }, jump: function( index ) { // go to the requested slide var fwd; var opts = this.opts(); if ( opts.busy && ! opts.manualTrump ) return; var num = parseInt( index, 10 ); if (isNaN(num) || num < 0 || num >= opts.slides.length) { opts.API.log('goto: invalid slide index: ' + num); return; } if (num == opts.currSlide) { opts.API.log('goto: skipping, already on slide', num); return; } opts.nextSlide = num; clearTimeout(opts.timeoutId); opts.timeoutId = 0; opts.API.log('goto: ', num, ' (zero-index)'); fwd = opts.currSlide < opts.nextSlide; opts.API.prepareTx( true, fwd ); }, stop: function() { var opts = this.opts(); var pauseObj = opts.container; clearTimeout(opts.timeoutId); opts.timeoutId = 0; opts.API.stopTransition(); if ( opts.pauseOnHover ) { if ( opts.pauseOnHover !== true ) pauseObj = $( opts.pauseOnHover ); pauseObj.off('mouseenter mouseleave'); } opts.API.trigger('cycletwo-stopped', [ opts ]).log('cycletwo-stopped'); }, reinit: function() { var opts = this.opts(); opts.API.destroy(); opts.container.cycletwo(); }, remove: function( index ) { var opts = this.opts(); var slide, slideToRemove, slides = [], slideNum = 1; for ( var i=0; i < opts.slides.length; i++ ) { slide = opts.slides[i]; if ( i == index ) { slideToRemove = slide; } else { slides.push( slide ); $( slide ).data('cycletwo.opts').slideNum = slideNum; slideNum++; } } if ( slideToRemove ) { opts.slides = $( slides ); opts.slideCount--; $( slideToRemove ).remove(); if (index == opts.currSlide) opts.API.advanceSlide( 1 ); else if ( index < opts.currSlide ) opts.currSlide--; else opts.currSlide++; opts.API.trigger('cycletwo-slide-removed', [ opts, index, slideToRemove ]).log('cycletwo-slide-removed'); opts.API.updateView(); } } }); // listen for clicks on elements with data-cycle-cmd attribute $(document).on('click.cycletwo', '[data-cycle-cmd]', function(e) { // issue cycletwo command e.preventDefault(); var el = $(this); var command = el.data('cycletwo-cmd'); var context = el.data('cycletwo-context') || '.cycletwo-slideshow'; $(context).cycletwo(command, el.data('cycletwo-arg')); }); })(jQuery); /*! hash plugin for cycletwo; version: 20130905 */ (function($) { "use strict"; $(document).on( 'cycletwo-pre-initialize', function( e, opts ) { onHashChange( opts, true ); opts._onHashChange = function() { onHashChange( opts, false ); }; $( window ).on( 'hashchange', opts._onHashChange); }); $(document).on( 'cycletwo-update-view', function( e, opts, slideOpts ) { if ( slideOpts.hash && ( '#' + slideOpts.hash ) != window.location.hash ) { opts._hashFence = true; window.location.hash = slideOpts.hash; } }); $(document).on( 'cycletwo-destroyed', function( e, opts) { if ( opts._onHashChange ) { $( window ).off( 'hashchange', opts._onHashChange ); } }); function onHashChange( opts, setStartingSlide ) { var hash; if ( opts._hashFence ) { opts._hashFence = false; return; } hash = window.location.hash.substring(1); opts.slides.each(function(i) { if ( $(this).data( 'cycletwo-hash' ) == hash ) { if ( setStartingSlide === true ) { opts.startingSlide = i; } else { var fwd = opts.currSlide < i; opts.nextSlide = i; opts.API.prepareTx( true, fwd ); } return false; } }); } })(jQuery); /*! loader plugin for cycletwo; version: 20130307 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { loader: false }); $(document).on( 'cycletwo-bootstrap', function( e, opts ) { var addFn; if ( !opts.loader ) return; // override API.add for this slideshow addFn = opts.API.add; opts.API.add = add; function add( slides, prepend ) { var slideArr = []; if ( $.type( slides ) == 'string' ) slides = $.trim( slides ); else if ( $.type( slides) === 'array' ) { for (var i=0; i < slides.length; i++ ) slides[i] = $(slides[i])[0]; } slides = $( slides ); var slideCount = slides.length; if ( ! slideCount ) return; slides.hide().appendTo('body').each(function(i) { // appendTo fixes #56 var count = 0; var slide = $(this); var images = slide.is('img') ? slide : slide.find('img'); slide.data('index', i); // allow some images to be marked as unimportant (and filter out images w/o src value) images = images.filter(':not(.cycletwo-loader-ignore)').filter(':not([src=""])'); if ( ! images.length ) { --slideCount; slideArr.push( slide ); return; } count = images.length; images.each(function() { // add images that are already loaded if ( this.complete ) { imageLoaded(); } else { $(this).load(function() { imageLoaded(); }).error(function() { if ( --count === 0 ) { // ignore this slide opts.API.log('slide skipped; img not loaded:', this.src); if ( --slideCount === 0 && opts.loader == 'wait') { addFn.apply( opts.API, [ slideArr, prepend ] ); } } }); } }); function imageLoaded() { if ( --count === 0 ) { --slideCount; addSlide( slide ); } } }); if ( slideCount ) opts.container.addClass('cycletwo-loading'); function addSlide( slide ) { var curr; if ( opts.loader == 'wait' ) { slideArr.push( slide ); if ( slideCount === 0 ) { // #59; sort slides into original markup order slideArr.sort( sorter ); addFn.apply( opts.API, [ slideArr, prepend ] ); opts.container.removeClass('cycletwo-loading'); } } else { curr = $(opts.slides[opts.currSlide]); addFn.apply( opts.API, [ slide, prepend ] ); curr.show(); opts.container.removeClass('cycletwo-loading'); } } function sorter(a, b) { return a.data('index') - b.data('index'); } } }); })(jQuery); /*! pager plugin for cycletwo; version: 20130525 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { pager: '> .cycletwo-pager', pagerActiveClass: 'cycletwo-pager-active', pagerEvent: 'click.cycletwo', pagerTemplate: '' }); $(document).on( 'cycletwo-bootstrap', function( e, opts, API ) { // add method to API API.buildPagerLink = buildPagerLink; }); $(document).on( 'cycletwo-slide-added', function( e, opts, slideOpts, slideAdded ) { if ( opts.pager ) { opts.API.buildPagerLink ( opts, slideOpts, slideAdded ); opts.API.page = page; } }); $(document).on( 'cycletwo-slide-removed', function( e, opts, index, slideRemoved ) { if ( opts.pager ) { var pagers = opts.API.getComponent( 'pager' ); pagers.each(function() { var pager = $(this); $( pager.children()[index] ).remove(); }); } }); $(document).on( 'cycletwo-update-view', function( e, opts, slideOpts ) { var pagers; if ( opts.pager ) { pagers = opts.API.getComponent( 'pager' ); pagers.each(function() { $(this).children().removeClass( opts.pagerActiveClass ) .eq( opts.currSlide ).addClass( opts.pagerActiveClass ); }); } }); $(document).on( 'cycletwo-destroyed', function( e, opts ) { var pager = opts.API.getComponent( 'pager' ); if ( pager ) { pager.children().off( opts.pagerEvent ); // #202 if ( opts.pagerTemplate ) pager.empty(); } }); function buildPagerLink( opts, slideOpts, slide ) { var pagerLink; var pagers = opts.API.getComponent( 'pager' ); pagers.each(function() { var pager = $(this); if ( slideOpts.pagerTemplate ) { var markup = opts.API.tmpl( slideOpts.pagerTemplate, slideOpts, opts, slide[0] ); pagerLink = $( markup ).appendTo( pager ); } else { pagerLink = pager.children().eq( opts.slideCount - 1 ); } pagerLink.on( opts.pagerEvent, function(e) { e.preventDefault(); opts.API.page( pager, e.currentTarget); }); }); } function page( pager, target ) { /*jshint validthis:true */ var opts = this.opts(); if ( opts.busy && ! opts.manualTrump ) return; var index = pager.children().index( target ); var nextSlide = index; var fwd = opts.currSlide < nextSlide; if (opts.currSlide == nextSlide) { return; // no op, clicked pager for the currently displayed slide } opts.nextSlide = nextSlide; opts.API.prepareTx( true, fwd ); opts.API.trigger('cycletwo-pager-activated', [opts, pager, target ]); } })(jQuery); /*! prevnext plugin for cycletwo; version: 20130709 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { next: '> .cycletwo-next', nextEvent: 'click.cycletwo', disabledClass: 'disabled', prev: '> .cycletwo-prev', prevEvent: 'click.cycletwo', swipe: false }); $(document).on( 'cycletwo-initialized', function( e, opts ) { opts.API.getComponent( 'next' ).on( opts.nextEvent, function(e) { e.preventDefault(); opts.API.next(); }); opts.API.getComponent( 'prev' ).on( opts.prevEvent, function(e) { e.preventDefault(); opts.API.prev(); }); if ( opts.swipe ) { var nextEvent = opts.swipeVert ? 'swipeUp.cycletwo' : 'swipeLeft.cycletwo swipeleft.cycletwo'; var prevEvent = opts.swipeVert ? 'swipeDown.cycletwo' : 'swipeRight.cycletwo swiperight.cycletwo'; opts.container.on( nextEvent, function(e) { opts.API.next(); }); opts.container.on( prevEvent, function() { opts.API.prev(); }); } }); $(document).on( 'cycletwo-update-view', function( e, opts, slideOpts, currSlide ) { if ( opts.allowWrap ) return; var cls = opts.disabledClass; var next = opts.API.getComponent( 'next' ); var prev = opts.API.getComponent( 'prev' ); var prevBoundry = opts._prevBoundry || 0; var nextBoundry = (opts._nextBoundry !== undefined)?opts._nextBoundry:opts.slideCount - 1; if ( opts.currSlide == nextBoundry ) next.addClass( cls ).prop( 'disabled', true ); else next.removeClass( cls ).prop( 'disabled', false ); if ( opts.currSlide === prevBoundry ) prev.addClass( cls ).prop( 'disabled', true ); else prev.removeClass( cls ).prop( 'disabled', false ); }); $(document).on( 'cycletwo-destroyed', function( e, opts ) { opts.API.getComponent( 'prev' ).off( opts.nextEvent ); opts.API.getComponent( 'next' ).off( opts.prevEvent ); opts.container.off( 'swipeleft.cycletwo swiperight.cycletwo swipeLeft.cycletwo swipeRight.cycletwo swipeUp.cycletwo swipeDown.cycletwo' ); }); })(jQuery); /*! progressive loader plugin for cycletwo; version: 20130315 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { progressive: false }); $(document).on( 'cycletwo-pre-initialize', function( e, opts ) { if ( !opts.progressive ) return; var API = opts.API; var nextFn = API.next; var prevFn = API.prev; var prepareTxFn = API.prepareTx; var type = $.type( opts.progressive ); var slides, scriptEl; if ( type == 'array' ) { slides = opts.progressive; } else if ($.isFunction( opts.progressive ) ) { slides = opts.progressive( opts ); } else if ( type == 'string' ) { scriptEl = $( opts.progressive ); slides = $.trim( scriptEl.html() ); if ( !slides ) return; // is it json array? if ( /^(\[)/.test( slides ) ) { try { slides = $.parseJSON( slides ); } catch(err) { API.log( 'error parsing progressive slides', err ); return; } } else { // plain text, split on delimeter slides = slides.split( new RegExp( scriptEl.data('cycletwo-split') || '\n') ); // #95; look for empty slide if ( ! slides[ slides.length - 1 ] ) slides.pop(); } } if ( prepareTxFn ) { API.prepareTx = function( manual, fwd ) { var index, slide; if ( manual || slides.length === 0 ) { prepareTxFn.apply( opts.API, [ manual, fwd ] ); return; } if ( fwd && opts.currSlide == ( opts.slideCount-1) ) { slide = slides[ 0 ]; slides = slides.slice( 1 ); opts.container.one('cycletwo-slide-added', function(e, opts ) { setTimeout(function() { opts.API.advanceSlide( 1 ); },50); }); opts.API.add( slide ); } else if ( !fwd && opts.currSlide === 0 ) { index = slides.length-1; slide = slides[ index ]; slides = slides.slice( 0, index ); opts.container.one('cycletwo-slide-added', function(e, opts ) { setTimeout(function() { opts.currSlide = 1; opts.API.advanceSlide( -1 ); },50); }); opts.API.add( slide, true ); } else { prepareTxFn.apply( opts.API, [ manual, fwd ] ); } }; } if ( nextFn ) { API.next = function() { var opts = this.opts(); if ( slides.length && opts.currSlide == ( opts.slideCount - 1 ) ) { var slide = slides[ 0 ]; slides = slides.slice( 1 ); opts.container.one('cycletwo-slide-added', function(e, opts ) { nextFn.apply( opts.API ); opts.container.removeClass('cycletwo-loading'); }); opts.container.addClass('cycletwo-loading'); opts.API.add( slide ); } else { nextFn.apply( opts.API ); } }; } if ( prevFn ) { API.prev = function() { var opts = this.opts(); if ( slides.length && opts.currSlide === 0 ) { var index = slides.length-1; var slide = slides[ index ]; slides = slides.slice( 0, index ); opts.container.one('cycletwo-slide-added', function(e, opts ) { opts.currSlide = 1; opts.API.advanceSlide( -1 ); opts.container.removeClass('cycletwo-loading'); }); opts.container.addClass('cycletwo-loading'); opts.API.add( slide, true ); } else { prevFn.apply( opts.API ); } }; } }); })(jQuery); /*! tmpl plugin for cycletwo; version: 20121227 */ (function($) { "use strict"; $.extend($.fn.cycletwo.defaults, { tmplRegex: '{{((.)?.*?)}}' }); $.extend($.fn.cycletwo.API, { tmpl: function( str, opts /*, ... */) { var regex = new RegExp( opts.tmplRegex || $.fn.cycletwo.defaults.tmplRegex, 'g' ); var args = $.makeArray( arguments ); args.shift(); return str.replace(regex, function(_, str) { var i, j, obj, prop, names = str.split('.'); for (i=0; i < args.length; i++) { obj = args[i]; if ( ! obj ) continue; if (names.length > 1) { prop = obj; for (j=0; j < names.length; j++) { obj = prop; prop = prop[ names[j] ] || str; } } else { prop = obj[str]; } if ($.isFunction(prop)) return prop.apply(obj, args); if (prop !== undefined && prop !== null && prop != str) return prop; } return str; }); } }); })(jQuery); // source --> https://www.saiseva.org/wp-content/plugins/testimonial-rotator/js/jquery.cycletwo.addons.js?ver=5.6.2 /*! ADDON: scrollVert Plugin for cycletwo2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ (function(a){"use strict",a.fn.cycletwo.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block"},a.animIn={top:0},a.animOut={top:d?e:-e}}}})(jQuery); /*! ADDON: IE-Fade Plugin for cycletwo2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ (function(a){function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}"use strict",a.extend(a.fn.cycletwo.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:1,display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})})(jQuery); /*! ADDON: swipe Plugin for cycletwo2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ (function(a){"use strict";var b="ontouchend"in document;a.event.special.swipe=a.event.special.swipe||{scrollSupressionThreshold:10,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:75,setup:function(){var b=a(this);b.bind("touchstart",function(c){function g(b){if(!f)return;var c=b.originalEvent.touches?b.originalEvent.touches[0]:b;e={time:(new Date).getTime(),coords:[c.pageX,c.pageY]},Math.abs(f.coords[0]-e.coords[0])>a.event.special.swipe.scrollSupressionThreshold&&b.preventDefault()}var d=c.originalEvent.touches?c.originalEvent.touches[0]:c,e,f={time:(new Date).getTime(),coords:[d.pageX,d.pageY],origin:a(c.target)};b.bind("touchmove",g).one("touchend",function(c){b.unbind("touchmove",g),f&&e&&e.time-f.timea.event.special.swipe.horizontalDistanceThreshold&&Math.abs(f.coords[1]-e.coords[1])e.coords[0]?"swipeleft":"swiperight"),f=e=undefined})})}},a.event.special.swipeleft=a.event.special.swipeleft||{setup:function(){a(this).bind("swipe",a.noop)}},a.event.special.swiperight=a.event.special.swiperight||a.event.special.swipeleft})(jQuery); /*! ADDON: center Plugin for cycletwo2; Copyright (c) 2012 M. Alsup; ver: 20140128 */ (function(e){"use strict";e.extend(e.fn.cycletwo.defaults,{centerHorz:!1,centerVert:!1}),e(document).on("cycletwo-pre-initialize",function(i,t){function n(){clearTimeout(c),c=setTimeout(l,50)}function s(){clearTimeout(c),clearTimeout(a),e(window).off("resize orientationchange",n)}function o(){t.slides.each(r)}function l(){r.apply(t.container.find("."+t.slideActiveClass)),clearTimeout(a),a=setTimeout(o,50)}function r(){var i=e(this),n=t.container.width(),s=t.container.height(),o=i.outerWidth(),l=i.outerHeight();o&&(t.centerHorz&&n>=o&&i.css("marginLeft",(n-o)/2),t.centerVert&&s>=l&&i.css("marginTop",(s-l)/2))}if(t.centerHorz||t.centerVert){var c,a;e(window).on("resize orientationchange load",n),t.container.on("cycletwo-destroyed",s),t.container.on("cycletwo-initialized cycletwo-slide-added cycletwo-slide-removed",function(){n()}),l()}})})(jQuery); /* ADDON: Flip Plugin for cycletwo2; Copyright (c) 2012 M. Alsup; v20141007 */ !function(a){"use strict";function b(b){return{preInit:function(a){a.slides.css(d)},transition:function(c,d,e,f,g){var h=c,i=a(d),j=a(e),k=h.speed/2;b.call(j,-90),j.css({display:"block",visibility:"visible","background-position":"-90px",opacity:1}),i.css("background-position","0px"),i.animate({backgroundPosition:90},{step:b,duration:k,easing:h.easeOut||h.easing,complete:function(){c.API.updateView(!1,!0),j.animate({backgroundPosition:0},{step:b,duration:k,easing:h.easeIn||h.easing,complete:g})}})}}}function c(b){return function(c){var d=a(this);d.css({"-webkit-transform":"rotate"+b+"("+c+"deg)","-moz-transform":"rotate"+b+"("+c+"deg)","-ms-transform":"rotate"+b+"("+c+"deg)","-o-transform":"rotate"+b+"("+c+"deg)",transform:"rotate"+b+"("+c+"deg)"})}}var d,e=document.createElement("div").style,f=a.fn.cycletwo.transitions,g=void 0!==e.transform||void 0!==e.MozTransform||void 0!==e.webkitTransform||void 0!==e.oTransform||void 0!==e.msTransform;g&&void 0!==e.msTransform&&(e.msTransform="rotateY(0deg)",e.msTransform||(g=!1)),g?(f.flipHorz=b(c("Y")),f.flipVert=b(c("X")),d={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(f.flipHorz=f.scrollHorz,f.flipVert=f.scrollVert||f.scrollHorz)}(jQuery); /* ADDON: Carousel Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20141007 */ !function(a){"use strict";a(document).on("cycletwo-bootstrap",function(a,b,c){"carousel"===b.fx&&(c.getSlideIndex=function(a){var b=this.opts()._carouselWrap.children(),c=b.index(a);return c%b.length},c.next=function(){var a=b.reverse?-1:1;b.allowWrap===!1&&b.currSlide+a>b.slideCount-b.carouselVisible||(b.API.advanceSlide(a),b.API.trigger("cycletwo-next",[b]).log("cycletwo-next"))})}),a.fn.cycletwo.transitions.carousel={preInit:function(b){b.hideNonActive=!1,b.container.on("cycletwo-destroyed",a.proxy(this.onDestroy,b.API)),b.API.stopTransition=this.stopTransition;for(var c=0;cb.slideCount&&(b.carouselVisible=b.slideCount-1);var h=b.carouselVisible||b.slides.length,i={display:g?"block":"inline-block",position:"static"};if(b.container.css({position:"relative",overflow:"hidden"}),b.slides.css(i),b._currSlide=b.currSlide,f=a('').prependTo(b.container).css({margin:0,padding:0,top:0,left:0,position:"absolute"}).append(b.slides),b._carouselWrap=f,g||f.css("white-space","nowrap"),b.allowWrap!==!1){for(d=0;d<(void 0===b.carouselVisible?2:1);d++){for(c=0;c0;var l=b._currSlide,m=b.slideCount-b.carouselVisible;i>0&&b.nextSlide>m&&l==m?i=0:i>0&&b.nextSlide>m?i=b.nextSlide-l-(b.nextSlide-m):0>i&&b.currSlide>m&&b.nextSlide>m?i=0:0>i&&b.currSlide>m?i+=b.currSlide-m:l=b.currSlide,g=this.getScroll(b,j,l,i),b.API.opts()._currSlide=b.nextSlide>m?m:b.nextSlide}else e&&0===b.nextSlide?(g=this.getDim(b,b.currSlide,j),f=this.genCallback(b,e,j,f)):e||b.nextSlide!=b.slideCount-1?g=this.getScroll(b,j,b.currSlide,i):(g=this.getDim(b,b.currSlide,j),f=this.genCallback(b,e,j,f));h[j?"top":"left"]=e?"-="+g:"+="+g,b.throttleSpeed&&(k=g/a(b.slides[0])[j?"height":"width"]()*b.speed),b._carouselWrap.animate(h,k,b.easing,f)},getDim:function(b,c,d){var e=a(b.slides[c]);return e[d?"outerHeight":"outerWidth"](!0)},getScroll:function(a,b,c,d){var e,f=0;if(d>0)for(e=c;c+d>e;e++)f+=this.getDim(a,e,b);else for(e=c;e>c+d;e--)f+=this.getDim(a,e,b);return f},genCallback:function(b,c,d,e){return function(){var c=a(b.slides[b.nextSlide]).position(),f=0-c[d?"top":"left"]+(b.carouselOffset||0);b._carouselWrap.css(b.carouselVertical?"top":"left",f),e()}},stopTransition:function(){var a=this.opts();a.slides.stop(!1,!0),a._carouselWrap.stop(!1,!0)},onDestroy:function(){var b=this.opts();b._carouselResizeThrottle&&a(window).off("resize",b._carouselResizeThrottle),b.slides.prependTo(b.container),b._carouselWrap.remove()}}}(jQuery);